callWith static method

Implementation

static Future<AppticsResponse> callWith(AppticsHttpRequest request) async {

  try {
    var url = Uri.https(
    request.baseDomain,
    request.urlPath,
    request.queryParams
    );

    AppticsDebugLog.info(url.toString());

    var response = await http.post(url, headers: request.headers, body: request.body);
    AppticsDebugLog.info(response.body);
    if (response.statusCode == 200) {
      return Future.value(AppticsResponse.fromJson(jsonDecode(response.body)));
    }
  } catch (exception) {
    AppticsDebugLog.error("Exception while making network call $exception");
  }
  return Future.value(AppticsResponse.failureResponse());
}