getCart method

Future<Cart> getCart(
  1. String cartId
)

Get cart information

Implementation

Future<Cart> getCart(String cartId) async {
  try {
    final response = await _client.guestRequest<Map<String, dynamic>>(
      '/rest/V1/guest-carts/$cartId',
    );

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