getAllDefaults method

Future<GenericServerResponse<BeaResultDefaults>> getAllDefaults(
  1. GenericServerInput input
)

Implementation

Future<GenericServerResponse<BeaResultDefaults>> getAllDefaults(GenericServerInput input) async {
  GenericServerResponse<BeaResultDefaults> genericServerResponse = new GenericServerResponse<BeaResultDefaults>();
  try{

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

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

    String jsonInput = '{"filter": "${input.basePagination.filter}",'
        '"sorting": "${input.basePagination.sorting}",'
        '"skipCount": ${input.basePagination.skipCount},'
        '"maxResultCount": ${input.basePagination.maxResultCount}}';

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

    switch(statusCode){
      case 200:
        genericServerResponse.data = BeaResultDefaults.fromJson(response.data['result']);
        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 defaults');
    FLog.error(
        className: this.runtimeType.toString(),
        methodName: "getAllDefaults",
        text: 'Error to get BEA defaults - $e');
    throw e;
  }

  return genericServerResponse;
}