//  Dealfly
//
//  Created by DT Team on 16/8/2023.
//  Copyright © 2023 Amine. All rights reserved.
//

import UIKit
import RealmSwift

class WTransactionParser: Parser {
    
    
    func parse() -> [WTransaction] {
        
        var list = [WTransaction]()
        
        if let myResult = self.result {
            
            
            if myResult.count > 0 {
                
               
                let size = myResult.count-1
                
                for index in 0...size {
                    
                    let object = myResult[ String(index) ]
                    
                    let myObject = WTransaction()
                    
                    myObject.id = object["id"].intValue
                    myObject.amount = object["amount_v"].stringValue
                    myObject.currency = object["currency"].stringValue
                    myObject.note = object["note"].stringValue
                    myObject.operation = object["operation"].stringValue
                    myObject.no = object["no"].stringValue
                    myObject.user_id = object["user_id"].intValue
                    myObject.date = object["created_at"].stringValue
                    
                    
                    list.append(myObject)
                    
                }
                
                
            }
            
            
            return list
        }
        
        return []
    }
    
}
