GetUserRolesAsync method

Future<GenericServerResponse<List<String>>> GetUserRolesAsync(
  1. GenericServerInput<GetUserRolesAsyncInput> input
)

Implementation

Future<GenericServerResponse<List<String>>> GetUserRolesAsync(GenericServerInput<GetUserRolesAsyncInput> input) async {
  GenericServerResponse<List<String>> genericServerResponse = new GenericServerResponse<List<String>>();
  try{

    if(input.input == null){
      throw new Exception("Input not found.");
    }

    String url = UrlUtils.getUrl(_baseUrl, UrlUtils.URL_GET_USER_ROLE);

    String jsonInput = input.input.toJson().toString();

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

    switch(statusCode){
      case 200:
        genericServerResponse.data = (response.data['result'] as List<dynamic>).cast<String>();
        break;
      case 500:
        BeaError error = BeaError.fromJson(response.data['error']);
        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('Error to get BEA roles');
    FLog.error(
        className: this.runtimeType.toString(),
        methodName: "GetUserRolesAsync",
        text: 'Error to get BEA roles - $e');
    throw e;
  }

  return genericServerResponse;
}