diff --git a/AutoCat2.xcodeproj/project.pbxproj b/AutoCat2.xcodeproj/project.pbxproj index 6e7632f..a6c7d72 100644 --- a/AutoCat2.xcodeproj/project.pbxproj +++ b/AutoCat2.xcodeproj/project.pbxproj @@ -67,6 +67,15 @@ 7AE32D6927F06536004EF6E0 /* CoreDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE32D6827F06536004EF6E0 /* CoreDataSource.swift */; }; 7AE32D6E27F06D2D004EF6E0 /* SwiftDate in Frameworks */ = {isa = PBXBuildFile; productRef = 7AE32D6D27F06D2D004EF6E0 /* SwiftDate */; }; 7AE32D7127F06DA4004EF6E0 /* DateSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE32D7027F06DA4004EF6E0 /* DateSection.swift */; }; + 929EDE7F27F89C3000E55F65 /* VEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE7E27F89C3000E55F65 /* VEngine.swift */; }; + 929EDE8127F8A75E00E55F65 /* VPhoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8027F8A75E00E55F65 /* VPhoto.swift */; }; + 929EDE8327F8C6C500E55F65 /* VOwnershipPeriod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8227F8C6C500E55F65 /* VOwnershipPeriod.swift */; }; + 929EDE8527F8CB0600E55F65 /* VEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8427F8CB0600E55F65 /* VEvent.swift */; }; + 929EDE8727F8E11E00E55F65 /* VOsago.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8627F8E11E00E55F65 /* VOsago.swift */; }; + 929EDE8927F8E65500E55F65 /* VAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8827F8E65500E55F65 /* VAd.swift */; }; + 929EDE8C27F8E87B00E55F65 /* VNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8B27F8E87B00E55F65 /* VNote.swift */; }; + 929EDE8E27F8F4F500E55F65 /* DebugInfoEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8D27F8F4F500E55F65 /* DebugInfoEntry.swift */; }; + 929EDE9027F8F76300E55F65 /* DebugInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929EDE8F27F8F76300E55F65 /* DebugInfo.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -180,6 +189,15 @@ 7AE32D6527F063A1004EF6E0 /* UIEdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIEdgeInsets.swift; sourceTree = ""; }; 7AE32D6827F06536004EF6E0 /* CoreDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataSource.swift; sourceTree = ""; }; 7AE32D7027F06DA4004EF6E0 /* DateSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSection.swift; sourceTree = ""; }; + 929EDE7E27F89C3000E55F65 /* VEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VEngine.swift; sourceTree = ""; }; + 929EDE8027F8A75E00E55F65 /* VPhoto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPhoto.swift; sourceTree = ""; }; + 929EDE8227F8C6C500E55F65 /* VOwnershipPeriod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VOwnershipPeriod.swift; sourceTree = ""; }; + 929EDE8427F8CB0600E55F65 /* VEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VEvent.swift; sourceTree = ""; }; + 929EDE8627F8E11E00E55F65 /* VOsago.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VOsago.swift; sourceTree = ""; }; + 929EDE8827F8E65500E55F65 /* VAd.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VAd.swift; sourceTree = ""; }; + 929EDE8B27F8E87B00E55F65 /* VNote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VNote.swift; sourceTree = ""; }; + 929EDE8D27F8F4F500E55F65 /* DebugInfoEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugInfoEntry.swift; sourceTree = ""; }; + 929EDE8F27F8F76300E55F65 /* DebugInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugInfo.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -416,14 +434,12 @@ 7A49F50427D406CB00AEAAE0 /* Models */ = { isa = PBXGroup; children = ( - 7A49F50527D406CB00AEAAE0 /* VBrand.swift */, + 929EDE8A27F8E84F00E55F65 /* vmodels */, 7A49F50627D406CB00AEAAE0 /* Vehicle.swift */, 7A49F50727D406CB00AEAAE0 /* User.swift */, 7A49F50827D406CB00AEAAE0 /* Response.swift */, 7A49F50927D406CB00AEAAE0 /* Settings.swift */, 7A49F50A27D406CB00AEAAE0 /* PlateNumber.swift */, - 7A49F50B27D406CB00AEAAE0 /* VName.swift */, - 7A1D80E727F30399007BD64F /* VModel.swift */, ); path = Models; sourceTree = ""; @@ -452,6 +468,25 @@ path = DataSource; sourceTree = ""; }; + 929EDE8A27F8E84F00E55F65 /* vmodels */ = { + isa = PBXGroup; + children = ( + 7A49F50527D406CB00AEAAE0 /* VBrand.swift */, + 7A49F50B27D406CB00AEAAE0 /* VName.swift */, + 7A1D80E727F30399007BD64F /* VModel.swift */, + 929EDE7E27F89C3000E55F65 /* VEngine.swift */, + 929EDE8027F8A75E00E55F65 /* VPhoto.swift */, + 929EDE8227F8C6C500E55F65 /* VOwnershipPeriod.swift */, + 929EDE8427F8CB0600E55F65 /* VEvent.swift */, + 929EDE8627F8E11E00E55F65 /* VOsago.swift */, + 929EDE8827F8E65500E55F65 /* VAd.swift */, + 929EDE8B27F8E87B00E55F65 /* VNote.swift */, + 929EDE8D27F8F4F500E55F65 /* DebugInfoEntry.swift */, + 929EDE8F27F8F76300E55F65 /* DebugInfo.swift */, + ); + path = vmodels; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -724,7 +759,10 @@ buildActionMask = 2147483647; files = ( 7A49F50D27D406CB00AEAAE0 /* Vehicle.swift in Sources */, + 929EDE8327F8C6C500E55F65 /* VOwnershipPeriod.swift in Sources */, + 929EDE8C27F8E87B00E55F65 /* VNote.swift in Sources */, 7A49F50327D406C300AEAAE0 /* VehicleService.swift in Sources */, + 929EDE8E27F8F4F500E55F65 /* DebugInfoEntry.swift in Sources */, 7A49F4DB27D4064500AEAAE0 /* AutoCatCore.docc in Sources */, 7A49F50227D406C300AEAAE0 /* StorageService.swift in Sources */, 7A49F4FE27D406BA00AEAAE0 /* AnyEncodable.swift in Sources */, @@ -733,10 +771,16 @@ 7A49F51127D406CB00AEAAE0 /* PlateNumber.swift in Sources */, 7A49F50C27D406CB00AEAAE0 /* VBrand.swift in Sources */, 7A49F51027D406CB00AEAAE0 /* Settings.swift in Sources */, + 929EDE9027F8F76300E55F65 /* DebugInfo.swift in Sources */, + 929EDE8927F8E65500E55F65 /* VAd.swift in Sources */, 7A49F4F927D406B200AEAAE0 /* Constants.swift in Sources */, + 929EDE8527F8CB0600E55F65 /* VEvent.swift in Sources */, 7A49F50F27D406CB00AEAAE0 /* Response.swift in Sources */, + 929EDE8127F8A75E00E55F65 /* VPhoto.swift in Sources */, 7A49F4FB27D406B200AEAAE0 /* Api.swift in Sources */, 7A49F51527D40C6100AEAAE0 /* AutoCat2.xcdatamodeld in Sources */, + 929EDE7F27F89C3000E55F65 /* VEngine.swift in Sources */, + 929EDE8727F8E11E00E55F65 /* VOsago.swift in Sources */, 7A49F50E27D406CB00AEAAE0 /* User.swift in Sources */, 7A49F4FA27D406B200AEAAE0 /* ApiError.swift in Sources */, 7AE32D7127F06DA4004EF6E0 /* DateSection.swift in Sources */, diff --git a/AutoCat2.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AutoCat2.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6a81f52..d07623f 100644 --- a/AutoCat2.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AutoCat2.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,41 +1,43 @@ { - "pins" : [ - { - "identity" : "differencekit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/ra1028/DifferenceKit", - "state" : { - "revision" : "62745d7780deef4a023a792a1f8f763ec7bf9705", - "version" : "1.2.0" + "object": { + "pins": [ + { + "package": "DifferenceKit", + "repositoryURL": "https://github.com/ra1028/DifferenceKit", + "state": { + "branch": null, + "revision": "62745d7780deef4a023a792a1f8f763ec7bf9705", + "version": "1.2.0" + } + }, + { + "package": "PKHUD", + "repositoryURL": "https://github.com/pkluz/PKHUD.git", + "state": { + "branch": null, + "revision": "8fd26f23057c6bebd6695524b1c3e05e93aba571", + "version": "5.4.0" + } + }, + { + "package": "SwiftDate", + "repositoryURL": "https://github.com/malcommac/SwiftDate", + "state": { + "branch": null, + "revision": "6190d0cefff3013e77ed567e6b074f324e5c5bf5", + "version": "6.3.1" + } + }, + { + "package": "SwiftEntryKit", + "repositoryURL": "https://github.com/huri000/SwiftEntryKit", + "state": { + "branch": null, + "revision": "5ad36cccf0c4b9fea32f4e9b17a8e38f07563ef0", + "version": "2.0.0" + } } - }, - { - "identity" : "pkhud", - "kind" : "remoteSourceControl", - "location" : "https://github.com/pkluz/PKHUD.git", - "state" : { - "revision" : "8fd26f23057c6bebd6695524b1c3e05e93aba571", - "version" : "5.4.0" - } - }, - { - "identity" : "swiftdate", - "kind" : "remoteSourceControl", - "location" : "https://github.com/malcommac/SwiftDate", - "state" : { - "revision" : "6190d0cefff3013e77ed567e6b074f324e5c5bf5", - "version" : "6.3.1" - } - }, - { - "identity" : "swiftentrykit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/huri000/SwiftEntryKit", - "state" : { - "revision" : "5ad36cccf0c4b9fea32f4e9b17a8e38f07563ef0", - "version" : "2.0.0" - } - } - ], - "version" : 2 + ] + }, + "version": 1 } diff --git a/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents b/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents index 8eb7acc..17290ec 100644 --- a/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents +++ b/AutoCatCore/AutoCat2.xcdatamodeld/Shared.xcdatamodel/contents @@ -1,5 +1,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -21,8 +51,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -34,10 +90,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + \ No newline at end of file diff --git a/AutoCatCore/Models/Vehicle.swift b/AutoCatCore/Models/Vehicle.swift index dca0cd1..15c88c4 100644 --- a/AutoCatCore/Models/Vehicle.swift +++ b/AutoCatCore/Models/Vehicle.swift @@ -20,6 +20,14 @@ public struct Vehicle: Decodable { public let isRightWheel: Bool? public let isJapanese: Bool? public let addedBy: String? + public let engine: VEngine? + public let photos: [VPhoto] + public let ownershipPeriods: [VOwnershipPeriod] + public let events: [VEvent] + public let osagoContracts: [VOsago] + public let ads: [VAd] + public let notes: [VNote] + public let debugInfo: DebugInfo? } extension CDVehicle: Dated { @@ -66,6 +74,14 @@ extension CDVehicle { self.isJapanese = vehicle.isJapanese ?? false self.addedBy = vehicle.addedBy self.synchronized = true + self.engine = CDVEngine(model: vehicle.engine, context: context) + self.photos = NSSet(array: vehicle.photos.map { CDVPhoto(model: $0, context: context) }) + self.ownershipPeriods = NSSet(array: vehicle.ownershipPeriods.map { CDVOwnershipPeriod(model: $0, context: context) }) + self.events = NSSet(array: vehicle.events.map { CDVEvent(model: $0, context: context) }) + self.osagoContracts = NSSet(array: vehicle.osagoContracts.map { CDVOsago(model: $0, context: context) }) + self.ads = NSSet(array: vehicle.ads.map { CDVAd(model: $0, context: context) }) + self.notes = NSSet(array: vehicle.notes.map { CDVNote(model: $0, context: context) }) + self.debugInfo = CDDebugInfo(model: vehicle.debugInfo, context: context) } public var unrecognized: Bool { diff --git a/AutoCatCore/Models/vmodels/DebugInfo.swift b/AutoCatCore/Models/vmodels/DebugInfo.swift new file mode 100644 index 0000000..2b0ec32 --- /dev/null +++ b/AutoCatCore/Models/vmodels/DebugInfo.swift @@ -0,0 +1,31 @@ +// +// DebugInfo.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 03.04.2022. +// + +import Foundation +import CoreData + +public struct DebugInfo: Decodable { + + let autocod: DebugInfoEntry? + let vin01vin: DebugInfoEntry? + let vin01base: DebugInfoEntry? + let vin01history: DebugInfoEntry? + let nomerogram: DebugInfoEntry? +} + +extension CDDebugInfo { + + convenience init(model: DebugInfo?, context: NSManagedObjectContext) { + self.init(context: context) + + self.autocod = CDDebugInfoEntry(model: model?.autocod, context: context) + self.vin01vin = CDDebugInfoEntry(model: model?.vin01vin, context: context) + self.vin01base = CDDebugInfoEntry(model: model?.vin01base, context: context) + self.vin01history = CDDebugInfoEntry(model: model?.vin01history, context: context) + self.nomerogram = CDDebugInfoEntry(model: model?.nomerogram, context: context) + } +} diff --git a/AutoCatCore/Models/vmodels/DebugInfoEntry.swift b/AutoCatCore/Models/vmodels/DebugInfoEntry.swift new file mode 100644 index 0000000..0d4ca5e --- /dev/null +++ b/AutoCatCore/Models/vmodels/DebugInfoEntry.swift @@ -0,0 +1,38 @@ +// +// DebugInfoEntry.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 03.04.2022. +// + +import Foundation +import CoreData + +public enum DebugInfoStatus: Int64 { + case success = 0 + case error = 1 + case warning = 2 +} + +public struct DebugInfoEntry: Decodable { + + let fields: Int64 + let error: String? + let status: Int64 +} + +extension CDDebugInfoEntry { + + convenience init(model: DebugInfoEntry?, context: NSManagedObjectContext) { + self.init(context: context) + + self.fields = model?.fields ?? 0 + self.error = model?.error + self.status = model?.status ?? 0 + } + + public var statusEnum: DebugInfoStatus { + get { DebugInfoStatus(rawValue: self.status)! } + set { self.status = newValue.rawValue } + } +} diff --git a/AutoCatCore/Models/vmodels/VAd.swift b/AutoCatCore/Models/vmodels/VAd.swift new file mode 100644 index 0000000..1b14678 --- /dev/null +++ b/AutoCatCore/Models/vmodels/VAd.swift @@ -0,0 +1,39 @@ +// +// VAd.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VAd: Decodable { + + let id: Int64 + let url: String? + let price: String? + let date: Double + let mileage: String? + let region: String? + let city: String? + let adDescription: String? + let photos: [String] +} + +extension CDVAd { + + convenience init(model: VAd?, context: NSManagedObjectContext) { + self.init(context: context) + + self.id = model?.id ?? 0 + self.url = model?.url + self.price = model?.price + self.date = model?.date ?? 0 + self.mileage = model?.mileage + self.region = model?.region + self.city = model?.city + self.adDescription = model?.adDescription + self.photos = model?.photos + } +} diff --git a/AutoCatCore/Models/VBrand.swift b/AutoCatCore/Models/vmodels/VBrand.swift similarity index 100% rename from AutoCatCore/Models/VBrand.swift rename to AutoCatCore/Models/vmodels/VBrand.swift diff --git a/AutoCatCore/Models/vmodels/VEngine.swift b/AutoCatCore/Models/vmodels/VEngine.swift new file mode 100644 index 0000000..126d023 --- /dev/null +++ b/AutoCatCore/Models/vmodels/VEngine.swift @@ -0,0 +1,31 @@ +// +// VEngine.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VEngine: Decodable { + + let number: String? + let volume: Int64? + let powerHp: Float? + let powerKw: Float? + let fuelType: String? +} + +extension CDVEngine { + + convenience init(model: VEngine?, context: NSManagedObjectContext) { + self.init(context: context) + + self.number = model?.number + self.volume = model?.volume ?? 0 + self.powerHp = model?.powerHp ?? 0 + self.powerKw = model?.powerKw ?? 0 + self.fuelType = model?.fuelType + } +} diff --git a/AutoCatCore/Models/vmodels/VEvent.swift b/AutoCatCore/Models/vmodels/VEvent.swift new file mode 100644 index 0000000..9f25507 --- /dev/null +++ b/AutoCatCore/Models/vmodels/VEvent.swift @@ -0,0 +1,35 @@ +// +// VEvent.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VEvent: Decodable { + + let id: String + let date: Double + let latitude: Double + let longitude: Double + let speed: Double + let direction: Double + let address: String? +} + +extension CDVEvent { + + convenience init(model: VEvent?, context: NSManagedObjectContext) { + self.init(context: context) + + self.id = model?.id + self.date = model?.date ?? 0 + self.latitude = model?.latitude ?? 0 + self.longitude = model?.longitude ?? 0 + self.speed = model?.speed ?? 0 + self.direction = model?.direction ?? 0 + self.address = model?.address + } +} diff --git a/AutoCatCore/Models/VModel.swift b/AutoCatCore/Models/vmodels/VModel.swift similarity index 100% rename from AutoCatCore/Models/VModel.swift rename to AutoCatCore/Models/vmodels/VModel.swift diff --git a/AutoCatCore/Models/VName.swift b/AutoCatCore/Models/vmodels/VName.swift similarity index 100% rename from AutoCatCore/Models/VName.swift rename to AutoCatCore/Models/vmodels/VName.swift diff --git a/AutoCatCore/Models/vmodels/VNote.swift b/AutoCatCore/Models/vmodels/VNote.swift new file mode 100644 index 0000000..40d01fa --- /dev/null +++ b/AutoCatCore/Models/vmodels/VNote.swift @@ -0,0 +1,29 @@ +// +// VNote.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VNote: Decodable { + + let id: String? + let user: String? + let date: Double + let text: String? +} + +extension CDVNote { + + convenience init(model: VNote?, context: NSManagedObjectContext) { + self.init(context: context) + + self.id = model?.id + self.user = model?.user + self.date = model?.date ?? 0 + self.text = model?.text + } +} diff --git a/AutoCatCore/Models/vmodels/VOsago.swift b/AutoCatCore/Models/vmodels/VOsago.swift new file mode 100644 index 0000000..20c17e9 --- /dev/null +++ b/AutoCatCore/Models/vmodels/VOsago.swift @@ -0,0 +1,41 @@ +// +// VOsago.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VOsago: Decodable { + + let date: Double + let number: String? + let vin: String? + let plateNumber: String? + let name: String? + let status: String? + let restrictions: String? + let insurant: String? + let owner: String? + let usageRegion: String? +} + +extension CDVOsago { + + convenience init(model: VOsago?, context: NSManagedObjectContext) { + self.init(context: context) + + self.date = model?.date ?? 0 + self.number = model?.number + self.vin = model?.vin + self.plateNumber = model?.plateNumber + self.name = model?.name + self.status = model?.status + self.restrictions = model?.restrictions + self.insurant = model?.insurant + self.owner = model?.owner + self.usageRegion = model?.usageRegion + } +} diff --git a/AutoCatCore/Models/vmodels/VOwnershipPeriod.swift b/AutoCatCore/Models/vmodels/VOwnershipPeriod.swift new file mode 100644 index 0000000..d0788a3 --- /dev/null +++ b/AutoCatCore/Models/vmodels/VOwnershipPeriod.swift @@ -0,0 +1,43 @@ +// +// VOwnershipPeriod.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VOwnershipPeriod: Decodable { + + let lastOperation: String? + let ownerType: String? + let from: Int64? + let to: Int64? + let region: String? + let registrationRegion: String? + let locality: String? + let code: String? + let street: String? + let building: String? + let inn: String? +} + +extension CDVOwnershipPeriod { + + convenience init(model: VOwnershipPeriod?, context: NSManagedObjectContext) { + self.init(context: context) + + self.lastOperation = model?.lastOperation + self.ownerType = model?.ownerType + self.from = model?.from ?? 0 + self.to = model?.to ?? 0 + self.region = model?.region + self.registrationRegion = model?.registrationRegion + self.locality = model?.locality + self.code = model?.locality + self.street = model?.street + self.building = model?.building + self.inn = model?.inn + } +} diff --git a/AutoCatCore/Models/vmodels/VPhoto.swift b/AutoCatCore/Models/vmodels/VPhoto.swift new file mode 100644 index 0000000..f79537b --- /dev/null +++ b/AutoCatCore/Models/vmodels/VPhoto.swift @@ -0,0 +1,29 @@ +// +// VPhoto.swift +// AutoCatCore +// +// Created by Selim Mustafaev on 02.04.2022. +// + +import Foundation +import CoreData + +public struct VPhoto: Decodable { + + let brand: String? + let model: String? + let date: Double + let url: String? +} + +extension CDVPhoto { + + convenience init(model: VPhoto?, context: NSManagedObjectContext) { + self.init(context: context) + + self.brand = model?.brand + self.model = model?.model + self.date = model?.date ?? 0 + self.url = model?.url + } +}