callBeneficiaryAPi method

Future<void> callBeneficiaryAPi(
  1. BuildContext context,
  2. String mobileNumber,
  3. String benID,
  4. String benStatement,
  5. String benType,
  6. int pos,
  7. String impsType,
)

Implementation

Future<void> callBeneficiaryAPi(
  BuildContext context,
  String mobileNumber,
  String benID,
  String benStatement,
  String benType,
  int pos,
  String impsType,
) async {
  Map<String, dynamic> requestBody = {
    "ApplicationType": kglobal.shared.applcationType,
   // "EntityID": kglobal.shared.EntityID,
    "Session": kglobal.shared.UserToken,
    'GeoLocation': kglobal.shared.geolocation,
    "MachineID": kglobal.shared.deviceID,
    'Mobilenumber': mobileNumber ?? '',
    'Platform': kglobal.shared.kPlatform,
    'ReqType': AppUrl.IMPS_Get_Beneficiery,
    'Statement': benStatement,
    'BeneficiaryType': benType,
    'BeneficiaryID': benID,
    'BeneficiaryName': '',
    'BeneficiaryBank': '',
    'BeneficiaryAccountNumber': '',
    'BeneficiaryIFSC': '',
    'BeneficiaryMobileNumber': '',
    'BeneficiaryMMID': '',
    'TPIN': '',
    'IMPS_IsVerification': '0',
  };
  print(requestBody);
  String bodyJson = jsonEncode(requestBody);

  auth.BeneficiaryListApi(context, bodyJson).then((value) {
    try {
      setBeneficiaryData(value);
      if (beneficiaryRes.value.responseCode == 99723) {
        //remove item
        AlertDialog(
          title: Text("success".tr),
          titleTextStyle: TextStyle(
            fontWeight: FontWeight.bold,
            color: Colors.black,
            fontSize: 20,
          ),
          actions: [
            ElevatedButton(
              onPressed: () {
                Navigator.of(context).pop();
              },
              child: Text("ok".tr),
            ),
          ],
          content: Text(beneficiaryRes.value.message.toString()),
        );
        update();
      } else if (beneficiaryRes.value.responseCode?.length == 4) {
        if ('GetBeneficiaries' == benStatement) {
          ifdcList = <BeneficiaryInfo>[].obs;
          ifdcListTempFilter = <BeneficiaryInfo>[].obs;
          mmidList = <BeneficiaryInfo>[].obs;
          mmidListTempFilter = <BeneficiaryInfo>[].obs;
          for (int i = 0; i < beneficiaryRes.value.info!.length; i++) {
            if (beneficiaryRes.value.info?[i].beneficiaryType == 'IFSC') {
              ifdcList.add(beneficiaryRes.value.info![i]);
              ifdcListTempFilter.add(beneficiaryRes.value.info![i]);
            } else {
              mmidList.add(beneficiaryRes.value.info![i]);
              mmidListTempFilter.add(beneficiaryRes.value.info![i]);
            }
          }
          print('BeneficiaryRes Res');
          //  print(beneficiaryRes.value.responseCode?.length);
          print("IFSC>> ${ifdcList.value?.length}");
          print("MMID>>${mmidList.value?.length}");
          update();
        } else if ('RemoveBeneficiary' == benStatement) {
          if (impsType == 'MMID') {
            //after deletion
            mmidList.removeAt(pos);
            mmidListTempFilter.removeAt(pos);
            update();
          } else {
            //after deletion
            ifdcList.removeAt(pos);
            ifdcListTempFilter.removeAt(pos);
            update();
          }
        } else {}
      } else {
        kglobal.shared.showSnack(context, true, beneficiaryRes.value.message ?? "");

        print('Logout error');
      }
    } on Exception catch (ex) {
      print(ex);
    }
  });
}