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