TestAddToCart method

Future TestAddToCart({
  1. dynamic test_id,
  2. dynamic package_id,
  3. dynamic context,
})

Implementation

Future TestAddToCart({test_id, package_id, context}) async {
  var decodedResponse;
  final ApiBody = {"test_id": test_id, "package_id": package_id};
  try {
    Map data = ApiBody;
    var body = jsonEncode(data);

    final response = await http.post(
      Uri.parse('${WELLNESS_URL}api/diagnostic/diagnostic-cart'),
      headers: {
        'Authorization': currentUserToken,
        "Content-Type": "application/json"
      },
      body: body,
    );
    decodedResponse = json.decode(response.body);
    if (decodedResponse['success'] == true) {
      return null;
    } else {
      Validator().errorMessage(
          context: context, message: "${decodedResponse['message']}");
    }
  } catch (e) {
    ErrorListner(
        apiname: 'api/diagnostic/diagnostic-cart',
        responsed: "${decodedResponse}",
        request: "${ApiBody}",
        app_error: '${e}');
  }
}