updateOrderWithMap method
Implementation
Future<WooOrder> updateOrderWithMap({
required int id,
required Map<String, dynamic> data,
bool? useFaker,
}) async {
final isUsingFaker = useFaker ?? this.useFaker;
if (isUsingFaker) {
return WooOrder(id: id);
}
try {
final response = await dio.put(
_OrderEndpoints.singleOrder(id),
data: data,
);
final message = (response.data)['message'] as String?;
if (response.statusCode != null &&
response.statusCode! >= 200 &&
response.statusCode! < 300) {
return WooOrder.fromJson(response.data);
} else {
throw Exception(message?.cleanErrorMessage);
}
} on DioException catch (e) {
final errorMsg = e.response?.data['message'] ?? e.message;
throw Exception('$errorMsg'.cleanErrorMessage);
} catch (e) {
throw Exception(e.toString().cleanErrorMessage);
}
}