linkNewUpiAccountWithUI method

void linkNewUpiAccountWithUI({
  1. required String? customerMobile,
  2. required String? color,
  3. required OnSuccess<List<UpiAccount>> onSuccess,
  4. required OnFailure<Error> onFailure,
})

Implementation

void linkNewUpiAccountWithUI({required String? customerMobile, required String? color , required OnSuccess<List<UpiAccount>> onSuccess,
  required OnFailure<Error> onFailure} ) async {
  try {

    if(!_isTurboPluginAvailable){
      _emitFailure(onFailure);
      return;
    }

    var requestLinkNewUpiAccountWithUI =  <String, dynamic>{
      "customerMobile": customerMobile,
      "color": color
    };

    final Map<dynamic, dynamic> getLinkedUpiAccountsResponse = await _channel.invokeMethod('linkNewUpiAccountWithUI', requestLinkNewUpiAccountWithUI);
    if(getLinkedUpiAccountsResponse["data"]!=""){
      onSuccess(_getUpiAccounts(getLinkedUpiAccountsResponse["data"]));
    }else {
      onFailure(Error(errorCode:"NO_ACCOUNT_FOUND" , errorDescription: "No Account Found"));
    }

  } on PlatformException catch (error) {
    onFailure(Error(errorCode:error.code , errorDescription: error.message!));
  }
}