getCurrentVersion method

Future<GenericServerResponse<GetCurrentMobileVersionOutput>> getCurrentVersion(
  1. GenericServerInput<GetCurrentMobileVersionInput> input
)

Implementation

Future<GenericServerResponse<GetCurrentMobileVersionOutput>> getCurrentVersion(GenericServerInput<GetCurrentMobileVersionInput> input) async {
  GenericServerResponse<GetCurrentMobileVersionOutput> genericServerResponse = new GenericServerResponse<GetCurrentMobileVersionOutput>();
  try{

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

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

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

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

    switch(statusCode){
      case 200:
        genericServerResponse.data = GetCurrentMobileVersionOutput.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 current mobile version BEA');
    FLog.error(
        className: this.runtimeType.toString(),
        methodName: "getCurrentVersion",
        text: 'Error to get current mobile version BEA - $e');
    throw e;
  }

  return genericServerResponse;
}