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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
21
lib/Data/Repository/Admintoken/Getadmintokenrepository.dart
Normal file
21
lib/Data/Repository/Admintoken/Getadmintokenrepository.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Admintoken/Admintokenresponse.dart';
|
||||
import '../../Provider/Admintoken/Getadmintokenprovider.dart';
|
||||
|
||||
class GetAdminTokenRepository{
|
||||
|
||||
GetAdminTokenProvider getAdminTokenProvider = GetAdminTokenProvider();
|
||||
|
||||
int? appLocationId;
|
||||
|
||||
Future<GetAdminToken?> getAdminToken() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
appLocationId = prefs.getInt('appLocationId');
|
||||
var result = await getAdminTokenProvider.getAdminToken('${ApiConstants.adminToken}/?applocationid=$appLocationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
17
lib/Data/Repository/Appcategory/Appcategoryrepository.dart
Normal file
17
lib/Data/Repository/Appcategory/Appcategoryrepository.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Appcategory/app_category_response.dart';
|
||||
import '../../Provider/Appcategory/Appcategoryprovider.dart';
|
||||
|
||||
class AppCategoryRepository{
|
||||
AppCategoryProvider appCategoryProvider = AppCategoryProvider();
|
||||
|
||||
Future<GetAppCategories?> getAppCategory() async {
|
||||
|
||||
return await appCategoryProvider.getAppCategory('https://fiesta.nearle.app/live/api/v1/mob/utils/getsubcategories');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
15
lib/Data/Repository/Applocation/Applocationrepository.dart
Normal file
15
lib/Data/Repository/Applocation/Applocationrepository.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Applocations/Applocationresponse.dart';
|
||||
import '../../Provider/Applocation/Applocationprovider.dart';
|
||||
|
||||
class AppLocationRepository{
|
||||
AppLocationProvider appLocationProvider = AppLocationProvider();
|
||||
|
||||
Future<GetAppLocations?> getAppLocations() async {
|
||||
|
||||
return await appLocationProvider.getAppLocations(ApiConstants.appLocations);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Request/Authentication/Createuser/Createuserresponse.dart';
|
||||
import '../../../../Model/Response/Authentication/Createtenantuser/Createtenantuserresponse.dart';
|
||||
import '../../../Provider/Authentication/Createtenantuser/Createtenantuserprovider.dart';
|
||||
|
||||
|
||||
class CreateTenantUserRepository{
|
||||
int? userId;
|
||||
CreateTenantUserProviders createTenantUserProviders =CreateTenantUserProviders();
|
||||
|
||||
Future<CreateTenantUserResponse?> createTenantUser(CreateTenantUser data) async {
|
||||
var result = await createTenantUserProviders.createTenantUser(data,'${ApiConstants.createTenantUser}');
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
15
lib/Data/Repository/Authentication/loginrepository.dart
Normal file
15
lib/Data/Repository/Authentication/loginrepository.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Request/Authentication/Loginrequest.dart';
|
||||
import '../../../Model/Response/Authentication/Loginresponse.dart';
|
||||
import '../../Provider/Authentication/loginprovider.dart';
|
||||
|
||||
class LoginRepository{
|
||||
LoginProvider loginProvider = LoginProvider();
|
||||
|
||||
Future<LoginResponse?> signIn(LoginRequest data) async {
|
||||
|
||||
return await loginProvider.signIn('https://fiesta.nearle.app/live/api/v1/mob/users/tenant/login',data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
lib/Data/Repository/CreateOrder/CreateOrderRepository.dart
Normal file
13
lib/Data/Repository/CreateOrder/CreateOrderRepository.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Request/Createorder/Createorderrequest.dart';
|
||||
import '../../../Model/Response/Createorder/CreateOrderResponsemodel.dart';
|
||||
import '../../Provider/CreatOrder/CreateOrderProvider.dart';
|
||||
|
||||
class CreateOrderRepository{
|
||||
CreateOrderProviders createOrderProviders =CreateOrderProviders();
|
||||
Future<CreateOrderResponse?>createOrder(CreateOrder data) async {
|
||||
var result = await createOrderProviders.createOrder(data,ApiConstants.createOrder);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import '../../../Helper/Constants/Apiconstants.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';
|
||||
import '../../Provider/Createcustomer/Createcustomerprovider.dart';
|
||||
|
||||
class CreateCustomerRepository{
|
||||
CreateCustomerProvider createCustomerProvider = CreateCustomerProvider();
|
||||
|
||||
Future<CreateCustomerResponse?> createCustomer(CreateCustomers data) async {
|
||||
var result = await createCustomerProvider.createCustomer(data,'${ApiConstants.createCustomer}');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<CreateDeliveryAddressResponse?> createDeliveryAddress(CreateDeliveryAddress data) async {
|
||||
var result = await createCustomerProvider.createDeliveryAddress(data,'${ApiConstants.createDeliveryAddress}');
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Customers/GetCustomerById/GetCustomerByTenantId.dart';
|
||||
import '../../../Model/Response/Customers/GetCustomerById/Getdropcustomerbytenantid.dart';
|
||||
import '../../Provider/Customers/getCustomerbytenantidprovider.dart';
|
||||
|
||||
|
||||
class GetCustomersByTenantIdRepository{
|
||||
GetCustomersByTenantIdProvider getCustomersByTenantIdProvider = GetCustomersByTenantIdProvider();
|
||||
int? tenantId;
|
||||
|
||||
Future<GetCustomerByTenantId?> getCustomerByTenantId() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=1&pagesize=20');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetCustomerByTenantId?> getCustomerKeywordByTenantId(keyword) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getCustomerByTenantId('${ApiConstants.getCustomerSearchByTenantId}/?tenantid=$tenantId&keyword=$keyword');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetCustomerByTenantId?> getTenantsByTenantId() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getTenantsByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&locationid=1');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetCustomerByTenantId?> getCustomerByPageLimitTenantId(page,limit) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getTenantsByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=$page&pagesize=$limit');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropCustomerByTenantId() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropCustomerKeywordByTenantId(keyword) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerSearchByTenantId}/?tenantid=$tenantId&keyword=$keyword');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropCustomerByPageLimitTenantId(page,limit) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getDropCustomerByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&pageno=$page&pagesize=$limit');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<GetDropCustomerByTenantId?> getDropTenantByTenantId() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var result = await getCustomersByTenantIdProvider.getDropTenantByTenantId('${ApiConstants.getCustomerByTenantId}/?tenantid=$tenantId&locationid=1');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Request/Location/Addlocation/Addlocationrequest.dart';
|
||||
import '../../../../Model/Response/Location/Addlocation/Addlocationresponse.dart';
|
||||
import '../../../Provider/Location/Addlocation/Addlocationprovider.dart';
|
||||
|
||||
class AddLocationRepository{
|
||||
|
||||
AddLocationProvider addLocationProvider = AddLocationProvider();
|
||||
|
||||
Future<AddLocationResponse?>addLocation(AddLocation data) async {
|
||||
var result = await addLocationProvider.addLocation(data,'${ApiConstants.createLocation}');
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
|
||||
import '../../../Provider/Location/GetLocation/getlocationprovider.dart';
|
||||
|
||||
|
||||
|
||||
class GetLocationsRepository{
|
||||
GetLocationsProvider getLocationsProvider = GetLocationsProvider();
|
||||
int tenantId = 0;
|
||||
int locationId = 0;
|
||||
|
||||
Future<GetLocationByTenantId?> getLocationById() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')!;
|
||||
locationId = prefs.getInt('locationId')!;
|
||||
var result = await getLocationsProvider.getLocationById('${ApiConstants.getLocationById}?tenantid=$tenantId',);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Request/Location/Updatelocation/Updatelocationrequest.dart';
|
||||
import '../../../../Model/Response/Location/Updatelocation/Updatelocationresponse.dart';
|
||||
import '../../../Provider/Location/Updatelocation/Updatelocationprovider.dart';
|
||||
|
||||
class UpdateLocationRepository{
|
||||
|
||||
UpdateLocationProvider updateLocationProvider =UpdateLocationProvider();
|
||||
|
||||
Future<UpdateLocationResponse?>updateLocation(UpdateLocation data) async {
|
||||
var result = await updateLocationProvider.updateLocation(data,ApiConstants.updateLocation);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
21
lib/Data/Repository/Notification/Notificationrepository.dart
Normal file
21
lib/Data/Repository/Notification/Notificationrepository.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Authentication/Sms/Smsresponse.dart';
|
||||
import '../../../Model/Response/Notification/Notificationresponse.dart';
|
||||
import '../../Provider/Notification/Notificationprovider.dart';
|
||||
|
||||
class NotificationRepository{
|
||||
NotificationProvider notificationProvider = NotificationProvider();
|
||||
|
||||
Future<NotificationResponse?> createNotification( data) async {
|
||||
var result = await notificationProvider.createNotification(data,ApiConstants.notifyUrl);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Future<NotificationResponse?> notifyRider( data) async {
|
||||
var result = await notificationProvider.NotifyRider(data,ApiConstants.notifyRider);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
61
lib/Data/Repository/Orders/Orderrepository.dart
Normal file
61
lib/Data/Repository/Orders/Orderrepository.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Orders/Getorderresponse.dart';
|
||||
import '../../Provider/Orders/Ordersprovider.dart';
|
||||
|
||||
class OrdersRepository {
|
||||
|
||||
int? tenantId;
|
||||
int? locationid;
|
||||
|
||||
OrdersProvider ordersProvider = OrdersProvider();
|
||||
|
||||
Future<GetOrders?> getOrders(String status) async {
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
locationid = prefs.getInt('locationId');
|
||||
var fromDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var toDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
|
||||
print('ddd $status');
|
||||
|
||||
// var fromDateTm = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
// var toDateTm = DateFormat("yyyy-MM-dd").format(DateTime.now().add(Duration(days: 1)));
|
||||
|
||||
var result = await ordersProvider.getOrders(
|
||||
'${ApiConstants.getOrders}/?tenantid=$tenantId&status=$status&fromdate=$fromDate&todate=$toDate&locationid=$locationid');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetOrders?> getCurrentOrders() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var fromDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var toDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var result = await ordersProvider.getOrders('${ApiConstants.getOrders}/?tenantid=$tenantId&status=ongoing&fromdate=$fromDate&todate=$toDate&locationid=$locationid');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetOrders?> getCompletedOrders() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var fromDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var toDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var result = await ordersProvider.getOrders('${ApiConstants.getOrders}/?tenantid=$tenantId&status=delivered&fromdate=$fromDate&todate=$toDate&locationid=$locationid');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetOrders?> getCancelledOrder() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
var fromDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var toDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var result = await ordersProvider.getOrders('${ApiConstants.getOrders}/?tenantid=$tenantId&status=cancelled&fromdate=$fromDate&todate=$toDate&locationid=$locationid');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
23
lib/Data/Repository/Rider/get_rider_repo.dart
Normal file
23
lib/Data/Repository/Rider/get_rider_repo.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Riders/get_rider_model.dart';
|
||||
import '../../Provider/Riders/get_rider_provider.dart';
|
||||
|
||||
class RidersRepository{
|
||||
|
||||
RidersProvider ridersProvider = RidersProvider();
|
||||
|
||||
int? tenantId = 0;
|
||||
int? locationId = 0;
|
||||
|
||||
Future<GetRiderPoolsModel?> getRiders(appLocationId) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
locationId = prefs.getInt('locationId');
|
||||
var result = await ridersProvider.getRiders('${ApiConstants.getRiders}?tenantid=${tenantId}&location=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
17
lib/Data/Repository/Staffs/Addstaff/Addstaffrepository.dart
Normal file
17
lib/Data/Repository/Staffs/Addstaff/Addstaffrepository.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Request/Staffs/Addstaffs/Addstaffsrequest.dart';
|
||||
import '../../../../Model/Response/Staffs/Addstaffs/Addstaffresponse.dart';
|
||||
import '../../../Provider/Staffs/Addstaffs/Addstaffprovider.dart';
|
||||
|
||||
class AddStaffRepository{
|
||||
AddStaffProvider addStaffProvider =AddStaffProvider();
|
||||
|
||||
Future<CreateStaffResponse?>addStaff(CreateStaffRequest data) async {
|
||||
var result = await addStaffProvider.addStaff(data,ApiConstants.createStaff);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
20
lib/Data/Repository/Staffs/Getstaffsrepository.dart
Normal file
20
lib/Data/Repository/Staffs/Getstaffsrepository.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Staffs/Getstaffsresponse.dart';
|
||||
import '../../Provider/Staffs/Staffsprovider.dart';
|
||||
|
||||
class GetStaffsRepository{
|
||||
|
||||
int? tenantId;
|
||||
|
||||
GetStaffsProvider getStaffsProvider = GetStaffsProvider();
|
||||
|
||||
Future<GetStaffsResponse?> getStaffs() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')!;
|
||||
var result = await getStaffsProvider.getStaffs('${ApiConstants.getStaffs}/?tenantid=$tenantId',);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
import '../../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../../Model/Request/Staffs/UpdateStaff/Updatestaffrequest.dart';
|
||||
import '../../../../Model/Response/Staffs/Updatestaff/Updatestaffresponse.dart';
|
||||
import '../../../Provider/Staffs/Updatestaff/Updatestaffprovider.dart';
|
||||
|
||||
class UpdateStaffRepository{
|
||||
UpdateStaffProvider updateStaffProvider = UpdateStaffProvider();
|
||||
|
||||
Future<UpdateStaffResponse?> updateStaff(UpdateStaffRequest data) async {
|
||||
var result = await updateStaffProvider.updateStaff(data,ApiConstants.updateStaff,);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
92
lib/Data/Repository/Summary/ordersrepository.dart
Normal file
92
lib/Data/Repository/Summary/ordersrepository.dart
Normal file
@@ -0,0 +1,92 @@
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.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';
|
||||
import '../../Provider/Summary/ordersprovider.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
class OrderSummaryRepository{
|
||||
OrderSummaryProvider orderSummaryProvider = OrderSummaryProvider();
|
||||
DateTime? now;
|
||||
int moduleId = 0;
|
||||
int tenantId = 0;
|
||||
int locationId = 0;
|
||||
int roleId = 0;
|
||||
int orderheaderId =0;
|
||||
|
||||
DateTime getDate(DateTime d) => DateTime(d.year, d.month, d.day);
|
||||
|
||||
|
||||
|
||||
Future<GetDeliveries?> getOrdersToday({String? keyword}) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
var keywordParam = keyword ?? '';
|
||||
roleId = prefs.getInt('roleId')??0;
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
var fromdate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var todate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
var result = await orderSummaryProvider.getDelivery('${ApiConstants.getDeliveries}/?tenantid=$tenantId&fromdate=$fromdate&todate=$todate''&status=delivered&pageno=1&pagesize=30&keyword=$keywordParam&locationid=$locationId',);
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetDeliveries?> getOrdersWeek({String? keyword}) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
roleId = prefs.getInt('roleid')??0;
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
final date = DateTime.now();
|
||||
var keywordParam = keyword ?? '';
|
||||
|
||||
DateTime start = getDate(date.subtract(Duration(days: date.weekday - 1,)));
|
||||
DateTime week = getDate(
|
||||
date.add(Duration(days: DateTime.daysPerWeek - date.weekday)));
|
||||
|
||||
|
||||
var fromdate = DateFormat("yyyy-MM-dd")
|
||||
.format(DateFormat("yyyy-MM-dd", "en_US").parse(start.toString()));
|
||||
var todate= DateFormat("yyyy-MM-dd")
|
||||
.format(DateFormat("yyyy-MM-dd", "en_US").parse(week.toString()));
|
||||
var result = await orderSummaryProvider.getDelivery('${ApiConstants.getDeliveries}/?tenantid=$tenantId&fromdate=$fromdate'
|
||||
'&todate=$todate&status=delivered&pageno=1&pagesize=30&keyword=$keywordParam&locationid=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetDeliveries?> getOrdersMonth({String? keyword}) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
roleId = prefs.getInt('roleid')??0;
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
now = DateTime.now();
|
||||
var keywordParam = keyword ?? '';
|
||||
DateTime lastDayOfMonth = new DateTime(now!.year, now!.month + 1, 0);
|
||||
DateTime firstDayOfMonth = new DateTime(now!.year, now!.month, 1);
|
||||
var fromdate = DateFormat("yyyy-MM-dd").format(
|
||||
DateFormat("yyyy-MM-dd", "en_US").parse(firstDayOfMonth.toString()));
|
||||
var todate = DateFormat("yyyy-MM-dd").format(
|
||||
DateFormat("yyyy-MM-dd", "en_US").parse(lastDayOfMonth.toString()));
|
||||
var result = await orderSummaryProvider.getDelivery('${ApiConstants.getDeliveries}/?tenantid=$tenantId&fromdate='
|
||||
'$fromdate&todate=$todate&status=delivered&pageno=1&pagesize=30&keyword=$keywordParam&locationid=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Future<OrderSummary?> getOrderSummary() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')!;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
var result = await orderSummaryProvider.getOrderSummary('${ApiConstants.getOrderSummary}/?tenantid=$tenantId&locationid=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<CancelOrderResponse?>updateOrders(CancelOrderRequest data) async {
|
||||
var result = await orderSummaryProvider.updateOrders(data,'${ApiConstants.updateOrderStatus}');
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Partners/Getpartnerinforequest.dart';
|
||||
import '../../Provider/TenantPartner/Tenantpartnerprovider.dart';
|
||||
|
||||
class GetPartnersRepository{
|
||||
GetPartnersProvider getPartnersProvider = GetPartnersProvider();
|
||||
|
||||
int tenantId = 0;
|
||||
|
||||
Future<GetPartnersInfo?> getPartners(locationId) async {
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
var result = await getPartnersProvider.getPartners("${ApiConstants.getPartnerInfo}?applocationid=$locationId",);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Tenantlocation/Getlocationbyidresponse.dart';
|
||||
import '../../../Model/Response/Tenantlocation/Locationbyid/Locationidresponse.dart';
|
||||
import '../../Provider/Tenantlocation/Getlocationprovider.dart';
|
||||
|
||||
|
||||
class GetLocationsRepository{
|
||||
GetLocationsProvider getLocationsProvider = GetLocationsProvider();
|
||||
int? tenantId;
|
||||
int? locationId;
|
||||
|
||||
Future<GetLocationByTenantId?> getTenantLocationById() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
var result = await getLocationsProvider.getTenantLocationById('${ApiConstants.getTenantLocationById}?tenantid=$tenantId&locationid=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<GetLocationByLocaionId?> getLocationById() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
var result = await getLocationsProvider.getLocationById('${ApiConstants.getLocationsById}?tenantid=$tenantId&locationid=$locationId',);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Appcategory/Appcategoryresponse.dart';
|
||||
import '../../Provider/Tenantmodulecategory/Categoryprovider.dart';
|
||||
|
||||
class GetTenantCategoriesRepository{
|
||||
|
||||
GetTenantCategoriesProvider getTenantCategoriesProvider = GetTenantCategoriesProvider();
|
||||
|
||||
// Future<AppCategory?> getTenantCategory() async {
|
||||
//
|
||||
// return await getTenantCategoriesProvider.getTenantCategory('${ApiConstants.appCategory}/?moduleid=6');
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Tenantpricing/Tenantpricingresponse.dart';
|
||||
import '../../Provider/Tenantpricing/Tenantchargesprovider.dart';
|
||||
|
||||
class TenantPricingRepository {
|
||||
TenantPricingProvider tenantChargesProvider =TenantPricingProvider();
|
||||
int tenantId = 0;
|
||||
|
||||
Future<GetTenantPricing?> getTenantPricing() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId')??0;
|
||||
var result = await tenantChargesProvider.getTenantPricing('${ApiConstants.getTenantPricing}/?tenantid=$tenantId',);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
27
lib/Data/Repository/Tenants/Tenantsrepository.dart
Normal file
27
lib/Data/Repository/Tenants/Tenantsrepository.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Response/Tenants/Tenantinforesponse.dart';
|
||||
import '../../Provider/Tenants/Tenantsprovider.dart';
|
||||
|
||||
class TenantRepository{
|
||||
int? tenantId;
|
||||
int? locationId;
|
||||
|
||||
TenantsProvider tenantsProvider = TenantsProvider();
|
||||
|
||||
Future<TenantInfo?> getTenantInfo() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId') ?? 0;
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
print(tenantId);
|
||||
var result = await tenantsProvider.getTenantInfo('${ApiConstants.getTenantInfo}/?tenantid=$tenantId&locationid=$locationId');
|
||||
// var result = await tenantsProvider.getTenantInfo('${ApiConstants.tenantInfo}/?tenantid=$tenantId');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
31
lib/Data/Repository/Users/user_repository.dart
Normal file
31
lib/Data/Repository/Users/user_repository.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Request/User/Updateuser/Updateuserrequest.dart';
|
||||
import '../../../Model/Response/User/Updateuser/Updateuserresponse.dart';
|
||||
import '../../../Model/Response/User/Usermodelresponse.dart';
|
||||
import '../../Provider/Users/user_provider.dart';
|
||||
|
||||
|
||||
class UserRepository {
|
||||
UserProvider userProvider = UserProvider();
|
||||
int? userId;
|
||||
int? locationId;
|
||||
|
||||
Future<UserModelResponse?> getUser(token) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
userId = prefs.getInt('userId');
|
||||
locationId = prefs.getInt('locationId')??0;
|
||||
|
||||
return await userProvider.getUser('${ApiConstants.user}/getusers?userid=$userId&locationid=$locationId',token);
|
||||
}
|
||||
|
||||
Future<UserUpdateResponse?> updateUser(UserUpdateRequest data) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
userId = prefs.getInt('userId');
|
||||
|
||||
return await userProvider.updateUser(data,ApiConstants.userUpdate,);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
46
lib/Data/Repository/products_repo/get_products.dart
Normal file
46
lib/Data/Repository/products_repo/get_products.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../Helper/Constants/Apiconstants.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';
|
||||
import '../../Provider/Products_provider/get_products.dart';
|
||||
|
||||
class ProductsRepository {
|
||||
|
||||
int? tenantId;
|
||||
int? locationId;
|
||||
|
||||
int? categoryId;
|
||||
|
||||
GetProductsProvider getProductsProvider = GetProductsProvider();
|
||||
|
||||
Future<GetProducts?> getProducts({int? subCategoryId, String? keyword}) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
tenantId = prefs.getInt('tenantId');
|
||||
locationId = prefs.getInt('locationId');
|
||||
categoryId = prefs.getInt('categoryId');
|
||||
|
||||
var result = await getProductsProvider.getProducts('https://fiesta.nearle.app/live/api/v1/mob/products/getlocationproducts?tenantid=${tenantId}&page=1&pagesize=40&locationid=$locationId');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Future<ProductUpdateResponse?> productUpdate(ProductUpdateRequest data) async {
|
||||
var result = await getProductsProvider.updateProducts(data, 'https://fiesta.nearle.app/live/api/v1/mob/products/updateproductlocation');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
String productDetail = "https://fiesta.nearle.app/live/api/v1/mob/orders/getorderdetails";
|
||||
|
||||
Future<ProductDetailResponse?> getProductDetail(int orderheaderid) async {
|
||||
var result = await getProductsProvider.getProductDetail('$productDetail?orderheaderid=$orderheaderid');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
18
lib/Data/Repository/update_delivery/create_delivery.dart
Normal file
18
lib/Data/Repository/update_delivery/create_delivery.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Request/create_delivery_request/create_delivery_request.dart';
|
||||
import '../../../Model/Response/create_delivery_response/create_delivery_request.dart';
|
||||
import '../../Provider/deliveries/create_delivery.dart';
|
||||
|
||||
class createDeliveryRepository {
|
||||
|
||||
CreateDeliveryProvider createDeliveryProvider = CreateDeliveryProvider();
|
||||
|
||||
Future<CreateDeliveryResponse?> createDelivery(List<CreateDelivery> data) async {
|
||||
var result = await createDeliveryProvider.createDelivery(data, ApiConstants.createDelivery);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
lib/Data/Repository/update_delivery/update_delivery.dart
Normal file
20
lib/Data/Repository/update_delivery/update_delivery.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import '../../../Helper/Constants/Apiconstants.dart';
|
||||
import '../../../Model/Request/update_delivery/update_delivery.dart';
|
||||
|
||||
import '../../../Model/Response/update_delivery_response/update_delivery_response.dart';
|
||||
import '../../Provider/deliveries/update_delivery_provider.dart';
|
||||
|
||||
|
||||
|
||||
class UpdateDeliveryRepository {
|
||||
|
||||
UpdateDeliveryProvider updateDeliveryProvider = UpdateDeliveryProvider();
|
||||
|
||||
Future<UpdateDeliveryResponse?> updateDelivery(UpdateDeliveryRequest data) async {
|
||||
var result = await updateDeliveryProvider.updateDelivery(data,ApiConstants.updateDelivery);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user