ios – Making an attempt to make Transaction Listing View with Plaid API

ios – Making an attempt to make Transaction Listing View with Plaid API


I’m working in Swift to attempt to make a listing view that exhibits all of the transactions linked from all of the accounts utilizing Plaid API. However after I run this I get nothing. I’ve tried a number of various things, however nothing is working.

import UIKit

class TransactionViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    
    @IBOutlet var tableView: UITableView!
    let communicator = ServerCommunicator()
    var transactions: [Transaction] = []
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        title = "Transactions"
        
        tableView.dataSource = self
        tableView.delegate = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "TransactionCell")
        
        fetchTransactions()
    }
    
    personal func fetchTransactions() {
        communicator.callMyServer(path: "/server/transactions/get", httpMethod: .get) { (consequence: Consequence<[Transaction], ServerCommunicator.Error>) in
            DispatchQueue.primary.async {
                swap consequence {
                case .success(let fetchedTransactions):
                    print("Fetched transactions: (fetchedTransactions)") // Debug: Print fetched transactions
                    self.transactions = fetchedTransactions
                    self.tableView.reloadData()
                case .failure(let error):
                    print("Did not fetch transactions: (error)") // Debug: Print error if fetch fails
                }
            }
        }
    }
    
    // MARK: - UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
        print("Variety of transactions: (transactions.depend)") // Debug: Print variety of rows within the desk
        return transactions.depend
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "TransactionCell", for: indexPath)
        let transaction = transactions[indexPath.row]
        
        // Debug: Print transaction information for every row
        print("Transaction at index (indexPath.row): (transaction.date), (transaction.description), $(transaction.quantity)")
        
        cell.textLabel?.textual content = "(transaction.date): (transaction.description) - $(transaction.quantity)"
        cell.detailTextLabel?.textual content = transaction.accountName
        return cell
    }
}

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.