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