getOrderComments method
Get order comments
Implementation
Future<List<OrderComment>> getOrderComments(String orderId) async {
try {
final response = await _client.authenticatedRequest<Map<String, dynamic>>(
'/rest/V1/orders/$orderId/comments',
);
if (response.statusCode == 200) {
final List<dynamic> comments = response.data!['items'] ?? [];
return comments
.map((comment) => OrderComment.fromJson(comment))
.toList();
} else {
throw Exception(
'Failed to get order comments: ${response.statusMessage}',
);
}
} on DioException catch (e) {
throw Exception('Failed to get order comments: ${e.message}');
} catch (e) {
throw Exception('Failed to get order comments: $e');
}
}