getShipment method

Future<Shipment> getShipment(
  1. String shipmentId
)

Get shipment details

Implementation

Future<Shipment> getShipment(String shipmentId) async {
  try {
    final response = await _client.authenticatedRequest<Map<String, dynamic>>(
      '/rest/V1/shipments/$shipmentId',
    );

    if (response.statusCode == 200) {
      return Shipment.fromJson(response.data!);
    } else {
      throw Exception('Failed to get shipment: ${response.statusMessage}');
    }
  } on DioException catch (e) {
    throw Exception('Failed to get shipment: ${e.message}');
  } catch (e) {
    throw Exception('Failed to get shipment: $e');
  }
}