cancelOrder method
Cancel order
Implementation
Future<bool> cancelOrder(String orderId, {String? reason}) async {
try {
final data = <String, dynamic>{};
if (reason != null) {
data['reason'] = reason;
}
final response = await _client.authenticatedRequest<Map<String, dynamic>>(
'/rest/V1/orders/$orderId/cancel',
options: Options(method: 'POST'),
data: data,
);
return response.statusCode == 200;
} on DioException catch (e) {
throw Exception('Failed to cancel order: ${e.message}');
} catch (e) {
throw Exception('Failed to cancel order: $e');
}
}