linkNewUpiAccount method

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

Implementation

void linkNewUpiAccount({
  required String? customerMobile,
  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('linkNewUpiAccount', 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!));
  }
}