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