feat: update success order
This commit is contained in:
@@ -302,6 +302,38 @@ class OrderRemoteDatasource {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Either<String, OrderDetailResponseModel>> getOrderById(
|
||||
{required String orderId}) async {
|
||||
try {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final response = await dio.get(
|
||||
'${Variables.baseUrl}/api/v1/orders/$orderId',
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Right(OrderDetailResponseModel.fromMap(response.data));
|
||||
} else {
|
||||
log("❌ OrderDetailResponseModel API call failed - Status: ${response.statusCode}");
|
||||
return const Left("Failed Load Data");
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorMessage = 'Something went wrong';
|
||||
log("💥 Dio error: ${e.message}");
|
||||
log("💥 Dio response: ${e.response?.data}");
|
||||
return Left(errorMessage);
|
||||
} catch (e) {
|
||||
log("💥 Unexpected error: $e");
|
||||
return Left("Unexpected Error: $e");
|
||||
}
|
||||
}
|
||||
|
||||
Future<Either<String, OrderDetailResponseModel>> createOrderWithPayment(
|
||||
OrderRequestModel orderModel,
|
||||
PaymentMethod payment,
|
||||
|
||||
Reference in New Issue
Block a user