isImpersonate method

Future<GenericServerResponse<bool>> isImpersonate()

Implementation

Future<GenericServerResponse<bool>> isImpersonate() async {

  GenericServerResponse<bool> genericServerResponse = new GenericServerResponse<bool>();

  try{
    String url = UrlUtils.getUrl(_baseUrl, UrlUtils.URL_IS_IMPERSONATOR);

    String jsonInput = '{}';

    Response response = await bsm!.genericBeaHttpPost(url, jsonInput);
    int? statusCode = response.statusCode;

    switch(statusCode){
      case 200:
        genericServerResponse.data = response.data['result'].toString().toLowerCase() == "true" ? true : false;
        break;
      case 500:
         var res = response.data['error'];
        BeaError? error = res == null ? res : BeaError.fromJson(res);
        if (error != null) {
          genericServerResponse.beaError = error;
        } else {
          genericServerResponse.beaError = new BeaError("Unknown Error", 0, "");
        }
        break;
      case 401:
        genericServerResponse.beaSession = new BeaSession(true);
        break;
    }
  }on Exception catch (e){
    print('BEA is Impersonate error');
    FLog.error(
        className: this.runtimeType.toString(),
        methodName: "isImpersonate",
        text: 'BEA is Impersonate error - $e');
    throw e;
  }

  return genericServerResponse;
}