import Foundation
import RealmSwift

class VehicleAd: Object, Decodable, Cloneable {
    @objc dynamic var id: Int = 0
    @objc dynamic var url: String?
    @objc dynamic var price: String?
    @objc dynamic var date: TimeInterval = Date().timeIntervalSince1970
    @objc dynamic var mileage: String?
    @objc dynamic var region: String?
    @objc dynamic var city: String?
    @objc dynamic var adDescription: String?
    var photos = List<String>()
    
    required init(copy: VehicleAd) {
        self.id = copy.id
        self.url = copy.url
        self.price = copy.price
        self.date = copy.date
        self.mileage = copy.mileage
        self.region = copy.region
        self.city = copy.city
        self.adDescription = copy.adDescription
        
        let photos = List<String>()
        photos.append(objectsIn: copy.photos)
        self.photos = photos
    }
    
    required init() {
        super.init()
    }
}
