Files
daily_mobileapp_merchant/lib/Data/Provider/Notification/Notificationprovider.dart
2026-05-27 10:35:09 +05:30

85 lines
2.4 KiB
Dart

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;
}
}