41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:cheminova/models/rd_placed_order_model.dart';
|
|
import 'package:cheminova/utils/api_urls.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:dio/dio.dart';
|
|
import '../models/rd_order_item_model.dart';
|
|
|
|
|
|
class RDOrderPlacedService {
|
|
final Dio _dio = Dio(); // Create Dio instance
|
|
|
|
Future<void> placRDeOrder(PlacedOrdersProcessing orderDetails, String token) async {
|
|
//try {
|
|
// logger.w("orderjson ${jsonEncode(orderDetails.toJson())}");
|
|
final response = await _dio.post(
|
|
'https://api.cnapp.co.in/api/pd-process-order', // Ensure this is your correct endpoint
|
|
data: jsonEncode(orderDetails.toJson()),
|
|
options: Options(
|
|
headers: {
|
|
'Authorization': 'Bearer $token',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
),
|
|
);
|
|
//logger.w("Status code,${response.statusCode}");
|
|
if (response.statusCode != 200) {
|
|
|
|
throw Exception('Failed to RD place order');
|
|
}
|
|
}
|
|
// on DioException catch (e) {
|
|
// print("DioException: ${e.message}");
|
|
// throw Exception('Failed to place order: ${e.message}');
|
|
// }
|
|
// catch (e) {
|
|
// print("General Exception: ${e.toString()}");
|
|
// throw Exception('Failed to place order: ${e.toString()}');
|
|
// }
|
|
}
|