second commit
This commit is contained in:
33
lib/Data/Provider/Admintoken/Getadmintokenprovider.dart
Normal file
33
lib/Data/Provider/Admintoken/Getadmintokenprovider.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Model/Response/Admintoken/Admintokenresponse.dart';
|
||||
|
||||
class GetAdminTokenProvider{
|
||||
|
||||
Future<GetAdminToken?> getAdminToken(String urldata,) async {
|
||||
GetAdminToken? getAdminToken;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
print('GetAdminToken!!!!!!!!${response.body}');
|
||||
print('GetAdminTokenproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getAdminToken = GetAdminToken.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print('printinerrorcatch${e.toString()}');
|
||||
print("error");
|
||||
}
|
||||
return getAdminToken;
|
||||
}
|
||||
|
||||
}
|
||||
69
lib/Data/Provider/Appcategory/Appcategoryprovider.dart
Normal file
69
lib/Data/Provider/Appcategory/Appcategoryprovider.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:logger/logger.dart';
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Response/Appcategory/Appcategoryresponse.dart';
|
||||
import '../../../Model/Response/Appcategory/app_category_response.dart';
|
||||
|
||||
|
||||
class AppCategoryProvider{
|
||||
|
||||
Future<GetAppCategories?> getAppCategory(String url) async {
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
);
|
||||
|
||||
logger.i('Category API URL: $url');
|
||||
logger.i('Status Code: ${response.statusCode}');
|
||||
logger.i('Response Body: ${response.body}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final Map<String, dynamic> json = jsonDecode(response.body);
|
||||
return GetAppCategories.fromJson(json);
|
||||
} else {
|
||||
logger.e('Failed to load categories: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e('Error in getAppCategory: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class SubCategoryProvider {
|
||||
final logger = Logger();
|
||||
|
||||
Future<List<SubCategory>> fetchSubCategories() async {
|
||||
const url = 'https://fiesta.nearle.app/live/api/v1/mob/utils/getsubcategories';
|
||||
try {
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
if (data['status'] == true && data['details'] != null) {
|
||||
final List list = data['details'];
|
||||
return list.map((e) => SubCategory.fromJson(e)).toList();
|
||||
} else {
|
||||
logger.w('No subcategories found or invalid response');
|
||||
return [];
|
||||
}
|
||||
} else {
|
||||
logger.e('Failed with status: ${response.statusCode}');
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e('Error fetching subcategories: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
29
lib/Data/Provider/Applocation/Applocationprovider.dart
Normal file
29
lib/Data/Provider/Applocation/Applocationprovider.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Response/Applocations/Applocationresponse.dart';
|
||||
|
||||
|
||||
class AppLocationProvider{
|
||||
|
||||
Future<GetAppLocations?> getAppLocations(String urldata,) async {
|
||||
GetAppLocations? getAppLocations;
|
||||
try {
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
print('getAppLocationsproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getAppLocations = GetAppLocations.fromJson(parsedJson);
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getAppLocations;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../../Model/Request/Authentication/Createuser/Createuserresponse.dart';
|
||||
import '../../../../Model/Response/Authentication/Createtenantuser/Createtenantuserresponse.dart';
|
||||
|
||||
|
||||
|
||||
class CreateTenantUserProviders{
|
||||
|
||||
Future<CreateTenantUserResponse?> createTenantUser(CreateTenantUser data,String urldata,) async {
|
||||
CreateTenantUserResponse? createTenantUserResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('CreateTenantUserresponsebody ${response.body}');
|
||||
print('CreateTenantUserdata ${data.toJson()}');
|
||||
print('CreateTenantUserdatatenantlocations ${data.tenantlocations!.toJson()}');
|
||||
print('CreateTenantUserdatatenantsubscriptions ${data.tenantsubscriptions!.toJson()}');
|
||||
print('CreateTenantUserurlsssssssssss ${urldata.toString()}');
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
|
||||
|
||||
|
||||
createTenantUserResponse = CreateTenantUserResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider${createTenantUserResponse}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createTenantUserResponse;
|
||||
}
|
||||
|
||||
}
|
||||
43
lib/Data/Provider/Authentication/loginprovider.dart
Normal file
43
lib/Data/Provider/Authentication/loginprovider.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Model/Request/Authentication/Loginrequest.dart';
|
||||
import '../../../Model/Response/Authentication/Loginresponse.dart';
|
||||
|
||||
class LoginProvider{
|
||||
|
||||
Future<LoginResponse?> signIn(String urldata, LoginRequest data) async {
|
||||
LoginResponse? loginResponse;
|
||||
|
||||
try {
|
||||
final url = Uri.parse(urldata);
|
||||
final response = await post(url,
|
||||
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
}
|
||||
);
|
||||
print('urldatasssssssssssssss $urldata');
|
||||
print('LoginRequestdata ${data.toJson()}');
|
||||
print("signIncontactnosss${data.contactno}");
|
||||
print("signIndevicetype${data.devicetype}");
|
||||
print("signInconfigid${data.configid}");
|
||||
print("deviceidsssssssss${data.deviceid}");
|
||||
print("customertokensssss${data.userfcmtoken}");
|
||||
print("responseeeeeedata ${response.body}");
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
loginResponse = LoginResponse.fromJson(parsedJson);
|
||||
print('provider result$loginResponse');
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("errr");
|
||||
}
|
||||
return loginResponse;
|
||||
}
|
||||
|
||||
}
|
||||
44
lib/Data/Provider/CreatOrder/CreateOrderProvider.dart
Normal file
44
lib/Data/Provider/CreatOrder/CreateOrderProvider.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/Createorder/Createorderrequest.dart';
|
||||
import '../../../Model/Response/Createorder/CreateOrderResponsemodel.dart';
|
||||
|
||||
class CreateOrderProviders{
|
||||
Future<CreateOrderResponse?> createOrder(CreateOrder data,String urldata,) async {
|
||||
CreateOrderResponse? createOrder;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('CreateOrderresponsebody ${response.body}');
|
||||
print('CreateOrderdatatoJson ${data.toJson()}');
|
||||
print('pickuplocationid ${data.pickup?.customerid}');
|
||||
print('droplocationid ${data.drop?.customerid}');
|
||||
logger.i(json.encode(data.toJson()));
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('CreateOrderurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
createOrder = CreateOrderResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider${createOrder}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createOrder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
69
lib/Data/Provider/Createcustomer/Createcustomerprovider.dart
Normal file
69
lib/Data/Provider/Createcustomer/Createcustomerprovider.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Request/Authentication/Createuser/Createdeliveryaddress/Createdeliveryaddressrequest.dart';
|
||||
import '../../../Model/Request/Createcustomer/Createcustomerrequest.dart';
|
||||
import '../../../Model/Response/Createcustomer/Createcustomerresponse.dart';
|
||||
import '../../../Model/Response/Createcustomer/Createdeliveryaddress/Createdeliveryaddressresponsel.dart';
|
||||
|
||||
class CreateCustomerProvider{
|
||||
|
||||
Future<CreateCustomerResponse?> createCustomer(CreateCustomers data,String urldata,) async {
|
||||
CreateCustomerResponse? createCustomers;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('createCustomercontactno${data.firstname}');
|
||||
print('createCustomercontactno${data.contactno}');
|
||||
print('createCustomerapplocationid${data.applocationid}');
|
||||
print('createCustomercontactno${data}');
|
||||
|
||||
print('responsebodyincreatecustomer${response.body}');
|
||||
print('urldatacreatecustomer ${url}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
createCustomers = CreateCustomerResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createCustomers;
|
||||
}
|
||||
|
||||
Future<CreateDeliveryAddressResponse?> createDeliveryAddress(CreateDeliveryAddress data,String urldata,) async {
|
||||
CreateDeliveryAddressResponse? createDeliveryAddress;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('customeridinproviderdada${data.customerid}');
|
||||
print('responsebodyincreateDeliveryAddress ${response.body}');
|
||||
print('urldatacreateDeliveryAddress ${url}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
createDeliveryAddress = CreateDeliveryAddressResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createDeliveryAddress;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
142
lib/Data/Provider/Customers/getCustomerbytenantidprovider.dart
Normal file
142
lib/Data/Provider/Customers/getCustomerbytenantidprovider.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Response/Customers/GetCustomerById/GetCustomerByTenantId.dart';
|
||||
import '../../../Model/Response/Customers/GetCustomerById/Getdropcustomerbytenantid.dart';
|
||||
|
||||
|
||||
class GetCustomersByTenantIdProvider {
|
||||
|
||||
static const cacheKey = 'customerCache';
|
||||
final cacheManager = DefaultCacheManager();
|
||||
|
||||
Future<GetCustomerByTenantId?> getCustomerByTenantId(String urlData) async {
|
||||
GetCustomerByTenantId? getCustomerByTenantId;
|
||||
|
||||
logger.i('GetCustomerURL : ${urlData}');
|
||||
|
||||
try {
|
||||
/// 1. Attempt to load from cache first
|
||||
final fileInfo = await cacheManager.getFileFromCache(cacheKey);
|
||||
|
||||
String? cachedData;
|
||||
|
||||
if (fileInfo != null && fileInfo.file.existsSync()) {
|
||||
cachedData = await fileInfo.file.readAsString();
|
||||
final parsedJson = json.decode(cachedData);
|
||||
getCustomerByTenantId = GetCustomerByTenantId.fromJson(parsedJson);
|
||||
logger.i("......Customer data Loaded from cache......");
|
||||
}
|
||||
|
||||
/// 2.Always make a request to check for updates
|
||||
final response = await get(Uri.parse(urlData), headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final freshData = response.body;
|
||||
|
||||
/// Compare with cached data (optional optimization: hash/ETag/updatedAt)
|
||||
if (cachedData == null || freshData != cachedData) {
|
||||
logger.i("......Updating cache with fresh API data.......");
|
||||
|
||||
/// Update the cache with fresh data
|
||||
await cacheManager.putFile(
|
||||
cacheKey,
|
||||
response.bodyBytes,
|
||||
fileExtension: 'json',
|
||||
key: cacheKey,
|
||||
);
|
||||
|
||||
final parsedJson = json.decode(freshData);
|
||||
getCustomerByTenantId = GetCustomerByTenantId.fromJson(parsedJson);
|
||||
} else {
|
||||
logger.i(".........Customer API data is same as cache, no update required..........");
|
||||
}
|
||||
} else {
|
||||
logger.w("Customer API responded with status code: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e("Error fetching customer deals: $e");
|
||||
}
|
||||
|
||||
return getCustomerByTenantId;
|
||||
}
|
||||
|
||||
|
||||
Future<GetCustomerByTenantId?> getTenantsByTenantId(String urldata,) async {
|
||||
GetCustomerByTenantId? getCustomerByTenantId;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getCustomerByTenantId!!!!!!!!${response.body}');
|
||||
print('getCustomerByTenantIdproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getCustomerByTenantId = GetCustomerByTenantId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getCustomerByTenantId;
|
||||
}
|
||||
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropCustomerByTenantId(String urldata,) async {
|
||||
GetDropCustomerByTenantId? getDropCustomerByTenantId;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getDropCustomerByTenantIdresponse!!!!!!!!${response.body}');
|
||||
print('getDropCustomerByTenantIdproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getDropCustomerByTenantId = GetDropCustomerByTenantId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getDropCustomerByTenantId;
|
||||
}
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropTenantByTenantId(String urldata,) async {
|
||||
GetDropCustomerByTenantId? getDropCustomerByTenantId;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getDropCustomerByTenantIdresponse!!!!!!!!${response.body}');
|
||||
print('getDropCustomerByTenantIdproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getDropCustomerByTenantId = GetDropCustomerByTenantId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getDropCustomerByTenantId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Response/Getcustomeraddress/GetCustomerAddress.dart';
|
||||
|
||||
|
||||
class GetCustomersAddressProvider{
|
||||
|
||||
Future<GetCustomerAddress?> getCustomerAddress(String urldata,) async {
|
||||
GetCustomerAddress? getCustomerAddress;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getCustomerAddress!!!!!!!!${response.body}');
|
||||
print('getCustomerAddressproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getCustomerAddress = GetCustomerAddress.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getCustomerAddress;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Response/Getcustomerbynumber/Getcustomerbynumberresponse.dart';
|
||||
|
||||
class GetCustomersByNumberProvider{
|
||||
|
||||
Future<GetCustomerByNumber?> getCustomerByNumber(String urldata,) async {
|
||||
GetCustomerByNumber? getCustomerByNumber;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getCustomerByNumber!!!!!!!!${response.body}');
|
||||
print('getCustomerByNumberproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getCustomerByNumber = GetCustomerByNumber.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getCustomerByNumber;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../../Model/Request/Location/Addlocation/Addlocationrequest.dart';
|
||||
import '../../../../Model/Response/Location/Addlocation/Addlocationresponse.dart';
|
||||
|
||||
class AddLocationProvider{
|
||||
Future<AddLocationResponse?> addLocation(AddLocation data,String urldata,) async {
|
||||
AddLocationResponse? addLocationResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('addLocationResponseresponsebody ${response.body}');
|
||||
print('addLocationResponsedatatoJson ${data.toJson()}');
|
||||
print('addLocationResponseresponseorderdate ${data.tenantid}');
|
||||
print('addLocationResponseresponsetenantid ${data.locationid}');
|
||||
print('addLocationResponseresponsemoduleid ${data.moduleid}');
|
||||
print('addLocationResponseresponsepartnerid ${data.partnerid}');
|
||||
|
||||
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('addLocationResponseurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
addLocationResponse = AddLocationResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider $addLocationResponse');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return addLocationResponse;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
|
||||
|
||||
|
||||
class GetLocationsProvider{
|
||||
|
||||
Future<GetLocationByTenantId?> getLocationById(String urldata) async {
|
||||
GetLocationByTenantId? getLocationById;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata',);
|
||||
|
||||
final response = await http.get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
},
|
||||
);
|
||||
print('GetLocation!!!!!!!!${response.body}');
|
||||
print('GetLocationproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getLocationById = GetLocationByTenantId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getLocationById;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../../Model/Request/Location/Updatelocation/Updatelocationrequest.dart';
|
||||
import '../../../../Model/Response/Location/Updatelocation/Updatelocationresponse.dart';
|
||||
|
||||
class UpdateLocationProvider{
|
||||
|
||||
Future<UpdateLocationResponse?> updateLocation(UpdateLocation data,String urldata,) async {
|
||||
UpdateLocationResponse? updateLocationResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await put(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('updateLocationResponseresponsebody ${response.body}');
|
||||
print('updateLocationResponsedatatoJson ${data.toJson()}');
|
||||
print('updateLocationResponseresponseorderdate ${data.tenantid}');
|
||||
print('updateLocationResponseresponsetenantid ${data.locationid}');
|
||||
print('updateLocationResponseresponsemoduleid ${data.moduleid}');
|
||||
print('updateLocationResponseresponsepartnerid ${data.partnerid}');
|
||||
|
||||
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('CreateOrderurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
updateLocationResponse = UpdateLocationResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider $updateLocationResponse');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return updateLocationResponse;
|
||||
}
|
||||
|
||||
}
|
||||
85
lib/Data/Provider/Notification/Notificationprovider.dart
Normal file
85
lib/Data/Provider/Notification/Notificationprovider.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/Notification/Notification_request_rider.dart';
|
||||
import '../../../Model/Request/Notification/Notificationrequest.dart';
|
||||
import '../../../Model/Response/Authentication/Sms/Smsresponse.dart';
|
||||
import '../../../Model/Response/Notification/Notificationresponse.dart';
|
||||
|
||||
class NotificationProvider{
|
||||
|
||||
|
||||
Future<NotificationResponse?> createNotification(NotificationRequest data,String urldata,) async {
|
||||
NotificationResponse? notificationResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
logger.i(json.encode(data.toJson()));
|
||||
|
||||
print('notificationResponsebody ${response.body}');
|
||||
print('notificationdatatoJson ${data.toJson()}');
|
||||
|
||||
|
||||
print('CreateNotificationurlsssssssssss ${urldata.toString()}');
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
notificationResponse = NotificationResponse.fromJson(parsedJson);
|
||||
|
||||
print('createOrderinprovider ${notificationResponse.toJson()}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return notificationResponse;
|
||||
}
|
||||
|
||||
|
||||
Future<NotificationResponse?> NotifyRider(RiderNotificationRequest data,String urldata,) async {
|
||||
NotificationResponse? notificationResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
logger.i(json.encode(data.toJson()));
|
||||
|
||||
print('notificationResponsebody ${response.body}');
|
||||
print('notificationdatatoJson ${data.toJson()}');
|
||||
|
||||
|
||||
print('CreateNotificationurlsssssssssss ${urldata.toString()}');
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
notificationResponse = NotificationResponse.fromJson(parsedJson);
|
||||
|
||||
print('createOrderinprovider ${notificationResponse.toJson()}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return notificationResponse;
|
||||
}
|
||||
|
||||
}
|
||||
32
lib/Data/Provider/Orders/Ordersprovider.dart
Normal file
32
lib/Data/Provider/Orders/Ordersprovider.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'dart:convert';
|
||||
import 'package:NearleDailyBusiness/Helper/Logger.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../Model/Response/Orders/Getorderresponse.dart';
|
||||
|
||||
|
||||
class OrdersProvider {
|
||||
Future<GetOrders?> getOrders(String url) async {
|
||||
try {
|
||||
print('🌐 GetOrderUrl : $url');
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
print('📦 Response Status: ${response.statusCode}');
|
||||
print('📦 Response Body: ${response.body}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
|
||||
logger.i("GetOrders Response: ${jsonEncode(data)}");
|
||||
|
||||
return GetOrders.fromJson(data);
|
||||
} else {
|
||||
print('❌ Failed to load orders: ${response.reasonPhrase}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print('🚨 Exception in getOrders: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
136
lib/Data/Provider/Products_provider/get_products.dart
Normal file
136
lib/Data/Provider/Products_provider/get_products.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/products/update_product.dart';
|
||||
import '../../../Model/Response/products/product_info.dart';
|
||||
import '../../../Model/Response/products/product_response.dart';
|
||||
import '../../../Model/Response/products/product_update_response.dart';
|
||||
|
||||
|
||||
|
||||
class GetProductsProvider {
|
||||
|
||||
static const cacheKey = 'productCache';
|
||||
final cacheManager = DefaultCacheManager();
|
||||
|
||||
Future<GetProducts?> getProducts(String urlData) async {
|
||||
GetProducts? getProducts;
|
||||
logger.i('Get all products url data : $urlData');
|
||||
|
||||
try {
|
||||
// 1. Cache first
|
||||
final fileInfo = await cacheManager.getFileFromCache(cacheKey);
|
||||
String? cachedData;
|
||||
if (fileInfo != null && fileInfo.file.existsSync()) {
|
||||
cachedData = await fileInfo.file.readAsString();
|
||||
getProducts = GetProducts.fromJson(json.decode(cachedData));
|
||||
logger.i("Loaded data from cache");
|
||||
}
|
||||
|
||||
// 2. Always hit the network
|
||||
final response = await http.get(
|
||||
Uri.parse(urlData),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final freshData = response.body;
|
||||
|
||||
print(response);
|
||||
|
||||
if (cachedData == null || freshData != cachedData) {
|
||||
logger.i("Updating cache with fresh data");
|
||||
await cacheManager.putFile(
|
||||
cacheKey,
|
||||
response.bodyBytes,
|
||||
fileExtension: 'json',
|
||||
key: cacheKey,
|
||||
);
|
||||
getProducts = GetProducts.fromJson(json.decode(freshData));
|
||||
} else {
|
||||
logger.i("Cache and API data identical – no update");
|
||||
}
|
||||
} else {
|
||||
logger.w("API status: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e("Error fetching products: $e");
|
||||
}
|
||||
|
||||
return getProducts;
|
||||
}
|
||||
|
||||
Future<ProductUpdateResponse?> updateProducts(
|
||||
ProductUpdateRequest data, String urldata) async {
|
||||
ProductUpdateResponse? productUpdateResponse;
|
||||
|
||||
try {
|
||||
final url = Uri.parse(urldata);
|
||||
final jsonBody = json.encode(data.toJson());
|
||||
|
||||
// 🔥 THIS IS WHAT YOU WANT TO SEE 🔥
|
||||
print('🚀 SENDING PUT REQUEST');
|
||||
print('URL: $url');
|
||||
print('HEADERS: ${{
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
}}');
|
||||
print('BODY → ${jsonBody}'); // ← Exact JSON being sent
|
||||
print('PRETTY BODY → ${const JsonEncoder.withIndent(' ').convert(data.toJson())}');
|
||||
|
||||
final response = await put(
|
||||
url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: jsonBody,
|
||||
);
|
||||
|
||||
print('✅ RESPONSE: ${response.statusCode}');
|
||||
print('Response Body: ${response.body}');
|
||||
|
||||
final parsedJson = json.decode(response.body);
|
||||
productUpdateResponse = ProductUpdateResponse.fromJson(parsedJson);
|
||||
|
||||
print('Parsed → $productUpdateResponse');
|
||||
|
||||
} catch (e) {
|
||||
print('❌ ERROR: $e');
|
||||
}
|
||||
|
||||
return productUpdateResponse;
|
||||
}
|
||||
|
||||
|
||||
Future<ProductDetailResponse?> getProductDetail(String urldata,) async {
|
||||
logger.i('UrlData for product Details : ${urldata}');
|
||||
ProductDetailResponse? getProductDetailResponse;
|
||||
try {
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
logger.i('Product Response ${response.body}');
|
||||
logger.i('Get product Details Response${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getProductDetailResponse = ProductDetailResponse.fromJson(parsedJson);
|
||||
} catch (e) {
|
||||
logger.i(e.toString());
|
||||
logger.i('error in productDetails${e.toString()}');
|
||||
logger.i("error");
|
||||
}
|
||||
return getProductDetailResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
34
lib/Data/Provider/Riders/get_rider_provider.dart
Normal file
34
lib/Data/Provider/Riders/get_rider_provider.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Response/Riders/get_rider_model.dart';
|
||||
|
||||
class RidersProvider {
|
||||
|
||||
Future<GetRiderPoolsModel?> getRiders(String urldata,) async {
|
||||
GetRiderPoolsModel? getRiderPoolsModel;
|
||||
|
||||
logger.i('GetRiderURlData : ${urldata}');
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getRiderPoolsModelresponsebody!!!!!!!!${response.body}');
|
||||
print('getRiderPoolsModelurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getRiderPoolsModel = GetRiderPoolsModel.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getRiderPoolsModel;
|
||||
}
|
||||
|
||||
}
|
||||
49
lib/Data/Provider/Staffs/Addstaffs/Addstaffprovider.dart
Normal file
49
lib/Data/Provider/Staffs/Addstaffs/Addstaffprovider.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../../Helper/Logger.dart';
|
||||
import '../../../../Model/Request/Staffs/Addstaffs/Addstaffsrequest.dart';
|
||||
import '../../../../Model/Response/Staffs/Addstaffs/Addstaffresponse.dart';
|
||||
|
||||
class AddStaffProvider{
|
||||
|
||||
Future<CreateStaffResponse?> addStaff(CreateStaffRequest data,String urldata,) async {
|
||||
CreateStaffResponse? createStaffResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('createStaffResponseresponsebody ${response.body}');
|
||||
print('createStaffResponsedatatoJson ${data.toJson()}');
|
||||
print('createStaffResponseresponseorderdate ${data.tenantid}');
|
||||
print('createStaffResponseresponsetenantid ${data.locationid}');
|
||||
print('createStaffResponseresponseconfigid ${data.configid}');
|
||||
print('createStaffResponseresponsepartnerid ${data.partnerid}');
|
||||
logger.i(json.encode(data.toJson()));
|
||||
|
||||
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('CreateOrderurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
createStaffResponse = CreateStaffResponse.fromJson(parsedJson);
|
||||
print('createOrderinprovider${createStaffResponse}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return createStaffResponse;
|
||||
}
|
||||
|
||||
}
|
||||
34
lib/Data/Provider/Staffs/Staffsprovider.dart
Normal file
34
lib/Data/Provider/Staffs/Staffsprovider.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Model/Response/Staffs/Getstaffsresponse.dart';
|
||||
|
||||
class GetStaffsProvider{
|
||||
|
||||
Future<GetStaffsResponse?> getStaffs(String urldata,) async {
|
||||
GetStaffsResponse? getStaffsResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('getStaffsResponse!!!!!!!!${response.body}');
|
||||
print('getStaffsproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getStaffsResponse = GetStaffsResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getStaffsResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../../Model/Request/Staffs/UpdateStaff/Updatestaffrequest.dart';
|
||||
import '../../../../Model/Response/Staffs/Updatestaff/Updatestaffresponse.dart';
|
||||
|
||||
class UpdateStaffProvider{
|
||||
|
||||
Future<UpdateStaffResponse?> updateStaff(UpdateStaffRequest data,String urldata,) async {
|
||||
UpdateStaffResponse? updateStaffResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await put(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('updateStaffResponseresponsebody ${response.body}');
|
||||
print('updateStaffResponsedatatoJson ${data.toJson()}');
|
||||
print('updateStaffResponseresponseorderdate ${data.tenantid}');
|
||||
print('updateStaffResponseresponsetenantid ${data.locationid}');
|
||||
print('updateStaffResponseresponsepartnerid ${data.partnerid}');
|
||||
|
||||
|
||||
|
||||
// print('headerssssssssss ${response.headers}');
|
||||
print('updateStaffssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
updateStaffResponse = UpdateStaffResponse.fromJson(parsedJson);
|
||||
print('updateStaffinprovider $updateStaffResponse');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return updateStaffResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
94
lib/Data/Provider/Summary/ordersprovider.dart
Normal file
94
lib/Data/Provider/Summary/ordersprovider.dart
Normal file
@@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/Orders/Cancelorderrequest.dart';
|
||||
import '../../../Model/Response/Summary/Cancelorderresponse.dart';
|
||||
import '../../../Model/Response/Summary/Getsummarysresponse.dart';
|
||||
import '../../../Model/Response/Summary/Ordersummaryresponse.dart';
|
||||
|
||||
|
||||
|
||||
class OrderSummaryProvider {
|
||||
|
||||
|
||||
|
||||
|
||||
// Fetch deliveries/orders from API
|
||||
Future<GetDeliveries?> getDelivery(String url) async {
|
||||
try {
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
print(url);
|
||||
print(response);
|
||||
final data = json.decode(response.body);
|
||||
return GetDeliveries.fromJson(data);
|
||||
} else {
|
||||
logger.e('Failed to load orders. Status code: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e('Error in getDelivery: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<OrderSummary?> getOrderSummary(String url) async {
|
||||
try {
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
print(url);
|
||||
print(response.body);
|
||||
final data = json.decode(response.body);
|
||||
return OrderSummary.fromJson(data);
|
||||
|
||||
} else {
|
||||
logger.e('Failed to load order summary. Status code: ${response.statusCode}');
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e('Error in getOrderSummary: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<CancelOrderResponse?> updateOrders(CancelOrderRequest data,String urldata,) async {
|
||||
CancelOrderResponse? updateOrder;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
|
||||
final response = await put(url,
|
||||
body: json.encode({
|
||||
"orderheaderid": data.orderheaderid,
|
||||
"orderstatus": "${data.orderstatus}",
|
||||
"cancelled": "${data.cancelled}"
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('updateOrderresponsebody ${response.body}');
|
||||
print('updateOrderurlsssssssssss ${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
updateOrder = CancelOrderResponse.fromJson(parsedJson);
|
||||
print('updateOrderinprovider${updateOrder}');
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return updateOrder;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
lib/Data/Provider/TenantPartner/Tenantpartnerprovider.dart
Normal file
33
lib/Data/Provider/TenantPartner/Tenantpartnerprovider.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Response/Partners/Getpartnerinforequest.dart';
|
||||
|
||||
class GetPartnersProvider{
|
||||
|
||||
Future<GetPartnersInfo?> getPartners(String urldata) async {
|
||||
GetPartnersInfo? getLocationById;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata',);
|
||||
|
||||
final response = await get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
},
|
||||
);
|
||||
print('getPartners!!!!!!!!${response.body}');
|
||||
print('getPartnersproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getLocationById = GetPartnersInfo.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getLocationById;
|
||||
}
|
||||
|
||||
}
|
||||
63
lib/Data/Provider/Tenantlocation/Getlocationprovider.dart
Normal file
63
lib/Data/Provider/Tenantlocation/Getlocationprovider.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
|
||||
import '../../../Model/Response/Tenantlocation/Locationbyid/Locationidresponse.dart';
|
||||
|
||||
|
||||
class GetLocationsProvider{
|
||||
|
||||
Future<GetLocationByTenantId?> getTenantLocationById(String urldata) async {
|
||||
GetLocationByTenantId? getLocationById;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata',);
|
||||
|
||||
final response = await http.get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
},
|
||||
);
|
||||
print('GetLocation!!!!!!!!${response.body}');
|
||||
print('GetLocationproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getLocationById = GetLocationByTenantId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getLocationById;
|
||||
}
|
||||
|
||||
Future<GetLocationByLocaionId?> getLocationById(String urldata) async {
|
||||
GetLocationByLocaionId? getLocationsById;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata',);
|
||||
|
||||
final response = await http.get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
},
|
||||
);
|
||||
print('getLocationById!!!!!!!!${response.body}');
|
||||
print('getLocationByIdproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getLocationsById = GetLocationByLocaionId.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getLocationsById;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
31
lib/Data/Provider/Tenantmodulecategory/Categoryprovider.dart
Normal file
31
lib/Data/Provider/Tenantmodulecategory/Categoryprovider.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../Model/Response/Appcategory/Appcategoryresponse.dart';
|
||||
|
||||
class GetTenantCategoriesProvider{
|
||||
|
||||
// Future<AppCategory?> getTenantCategory(String urldata,) async {
|
||||
// AppCategory? getCategories;
|
||||
// try {
|
||||
//
|
||||
// final url = Uri.parse('$urldata');
|
||||
//
|
||||
// final response = await http.get(url, headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'Accept': 'application/json',
|
||||
// // 'Authorization': '$token',
|
||||
// });
|
||||
// print('getCategories!!!!!!!!${response.body}');
|
||||
// print('getCategoriesproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
// Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
//
|
||||
// // getCategories = AppCategory.fromJson(parsedJson);
|
||||
//
|
||||
// } catch (e) {
|
||||
// print(e.toString());
|
||||
// print("error");
|
||||
// }
|
||||
// return getCategories;
|
||||
// }
|
||||
}
|
||||
33
lib/Data/Provider/Tenantpricing/Tenantchargesprovider.dart
Normal file
33
lib/Data/Provider/Tenantpricing/Tenantchargesprovider.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Model/Response/Tenantpricing/Tenantpricingresponse.dart';
|
||||
|
||||
|
||||
class TenantPricingProvider {
|
||||
Future<GetTenantPricing?> getTenantPricing(String urldata) async {
|
||||
GetTenantPricing? getTenantPricing;
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata',);
|
||||
|
||||
final response = await get(url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
},
|
||||
);
|
||||
print('getTenantPricingresponse!!!!!!!!${response.body}');
|
||||
print('getTenantPricingproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
getTenantPricing = GetTenantPricing.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return getTenantPricing;
|
||||
}
|
||||
|
||||
}
|
||||
70
lib/Data/Provider/Tenants/Tenantsprovider.dart
Normal file
70
lib/Data/Provider/Tenants/Tenantsprovider.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Response/Tenants/Tenantinforesponse.dart';
|
||||
|
||||
class TenantsProvider {
|
||||
static const cacheKey = 'TenantCache';
|
||||
final cacheManager = DefaultCacheManager();
|
||||
|
||||
Future<TenantInfo?> getTenantInfo(String urlData) async {
|
||||
TenantInfo? tenantInfo;
|
||||
|
||||
logger.i('TenantInfo URL data: ${urlData}');
|
||||
logger.i('TenantInfo URL data: $urlData'); // 👈 Add this here
|
||||
|
||||
|
||||
try {
|
||||
/// 1. Attempt to load from cache first
|
||||
final fileInfo = await cacheManager.getFileFromCache(cacheKey);
|
||||
|
||||
String? cachedData;
|
||||
|
||||
if (fileInfo != null && fileInfo.file.existsSync()) {
|
||||
cachedData = await fileInfo.file.readAsString();
|
||||
final parsedJson = json.decode(cachedData);
|
||||
tenantInfo = TenantInfo.fromJson(parsedJson);
|
||||
logger.i("......Loaded data from cache......");
|
||||
}
|
||||
|
||||
/// 2.Always make a request to check for updates
|
||||
final response = await get(Uri.parse(urlData), headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
});
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final freshData = response.body;
|
||||
|
||||
/// Compare with cached data (optional optimization: hash/ETag/updatedAt)
|
||||
if (cachedData == null || freshData != cachedData) {
|
||||
logger.i("......Updating TenantDetails cache with fresh API data.......");
|
||||
|
||||
/// Update the cache with fresh data
|
||||
await cacheManager.putFile(
|
||||
cacheKey,
|
||||
response.bodyBytes,
|
||||
fileExtension: 'json',
|
||||
key: cacheKey,
|
||||
);
|
||||
final parsedJson = json.decode(freshData);
|
||||
tenantInfo = TenantInfo.fromJson(parsedJson);
|
||||
} else {
|
||||
logger.i(".........Tenant Details API data is same as cache, no update required..........");
|
||||
}
|
||||
} else {
|
||||
logger.w("Tenant Details API responded with status code: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
logger.e("Error fetching customer deals: $e");
|
||||
}
|
||||
|
||||
return tenantInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
68
lib/Data/Provider/Users/user_provider.dart
Normal file
68
lib/Data/Provider/Users/user_provider.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
|
||||
import '../../../Model/Request/User/Updateuser/Updateuserrequest.dart';
|
||||
import '../../../Model/Response/User/Updateuser/Updateuserresponse.dart';
|
||||
import '../../../Model/Response/User/Usermodelresponse.dart';
|
||||
|
||||
|
||||
|
||||
class UserProvider {
|
||||
Future<UserModelResponse?> getUser(String urldata, String token) async {
|
||||
UserModelResponse? userProfile;
|
||||
// LoginProvider();
|
||||
try {
|
||||
|
||||
final url = Uri.parse('$urldata');
|
||||
final response = await http.get(url, headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'token':'$token',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
print('userproviderresponsebody!!!!!!!!${response.body}');
|
||||
print('userproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
userProfile = UserModelResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
|
||||
Future<UserUpdateResponse?> updateUser(UserUpdateRequest data,String urldata) async {
|
||||
UserUpdateResponse? userUpdateResponse;
|
||||
// LoginProvider();
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await put(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
print('userUpdateproviderresponsebody!!!!!!!!${response.body}');
|
||||
print('userUpdateproviderurldata!!!!!!!!${urldata.toString()}');
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
|
||||
|
||||
userUpdateResponse = UserUpdateResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return userUpdateResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
43
lib/Data/Provider/deliveries/create_delivery.dart
Normal file
43
lib/Data/Provider/deliveries/create_delivery.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/create_delivery_request/create_delivery_request.dart';
|
||||
import '../../../Model/Response/create_delivery_response/create_delivery_request.dart';
|
||||
|
||||
class CreateDeliveryProvider {
|
||||
|
||||
Future<CreateDeliveryResponse?> createDelivery(List<CreateDelivery> data,String urldata,) async {
|
||||
|
||||
CreateDeliveryResponse? createDeliveryResponse;
|
||||
logger.i('Url data for crate delivery : $urldata');
|
||||
logger.i('Json Encode : ${json.encode(data)}');
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await post(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
logger.i('create Delivery : ${response.body}');
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body);
|
||||
|
||||
createDeliveryResponse = CreateDeliveryResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
logger.i(e.toString());
|
||||
logger.i("error");
|
||||
}
|
||||
return createDeliveryResponse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
37
lib/Data/Provider/deliveries/update_delivery_provider.dart
Normal file
37
lib/Data/Provider/deliveries/update_delivery_provider.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart';
|
||||
import '../../../Helper/Logger.dart';
|
||||
import '../../../Model/Request/update_delivery/update_delivery.dart';
|
||||
import '../../../Model/Response/update_delivery_response/update_delivery_response.dart';
|
||||
|
||||
class UpdateDeliveryProvider {
|
||||
|
||||
Future<UpdateDeliveryResponse?> updateDelivery (UpdateDeliveryRequest data,String urldata,) async {
|
||||
UpdateDeliveryResponse? updateDeliveryResponse;
|
||||
try {
|
||||
|
||||
final url = Uri.parse(urldata);
|
||||
|
||||
final response = await put(url,
|
||||
body: json.encode(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
// 'Authorization': '$token',
|
||||
});
|
||||
|
||||
logger.i('Update Delivery Response : ${response.body}');
|
||||
|
||||
Map<String, dynamic> parsedJson = json.decode(response.body);
|
||||
|
||||
updateDeliveryResponse = UpdateDeliveryResponse.fromJson(parsedJson);
|
||||
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
print("error");
|
||||
}
|
||||
return updateDeliveryResponse;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user