addDeposite method

  1. @override
Future<Either<AppException, Response>> addDeposite(
  1. String bankName,
  2. String branch,
  3. String deposit,
  4. String transactionNumber,
  5. String file,
  6. String selectedPayment,
)
override

Implementation

@override
Future<Either<AppException, response.Response>> addDeposite(
    String bankName,
    String branch,
    String deposit,
    String transactionNumber,
    String file,
    String selectedPayment) async {
  try {
    final eitherType = await networkService.postFileUpload('getdata',
        data: {
          'action': 'lmddeposit-create',
          'bank_name': bankName,
          'branch': branch,
          'deposit_amount': deposit,
          'transaction_number': transactionNumber,
          'payment_type': selectedPayment == 'Cash' ? "1" : "2",
        },
        files: file.isNotEmpty ? [File(file)] : [],
        fileKey: 'image');
    return eitherType.fold(
      (exception) {
        return Left(exception);
      },
      (response) {
        return Right(response);
      },
    );
  } catch (e) {
    return Left(
      AppException(
        message: 'Unknown error occured',
        statusCode: 1,
        identifier: '${e.toString()}\nLoginUserRemoteDataSource.loginUser',
      ),
    );
  }
}