payfrit-food-ios/PayfritFood/Models/UserProfile.swift
John Pinkyfloyd 71e7ec34f6 Initial commit: PayfritFood iOS app
- SwiftUI + async/await architecture
- Barcode scanning with AVFoundation
- Product display with score ring, NOVA badge, nutrition
- Alternatives with sort/filter
- Auth (login/register)
- Favorites & history
- Account management
- Dark theme
- Connected to food.payfrit.com API (Open Food Facts proxy)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-16 16:58:21 -07:00

41 lines
1.2 KiB
Swift

import Foundation
struct UserProfile {
let id: Int
let email: String
let name: String
let zipCode: String
let isPremium: Bool
let createdAt: Date?
init(json: [String: Any]) {
id = JSON.parseInt(json["id"] ?? json["userId"] ?? json["UserID"])
email = JSON.parseString(json["email"] ?? json["Email"])
name = JSON.parseString(json["name"] ?? json["Name"])
zipCode = JSON.parseString(json["zipCode"] ?? json["ZipCode"] ?? json["zip"])
isPremium = JSON.parseBool(json["isPremium"] ?? json["IsPremium"] ?? json["premium"])
if let dateString = json["createdAt"] as? String ?? json["CreatedAt"] as? String {
let formatter = ISO8601DateFormatter()
createdAt = formatter.date(from: dateString)
} else {
createdAt = nil
}
}
init(
id: Int,
email: String,
name: String,
zipCode: String,
isPremium: Bool = false,
createdAt: Date? = nil
) {
self.id = id
self.email = email
self.name = name
self.zipCode = zipCode
self.isPremium = isPremium
self.createdAt = createdAt
}
}