import Foundation struct ServicePoint: Identifiable, Codable, Hashable { let id: String let name: String let businessId: String enum CodingKeys: String, CodingKey { case servicePointId = "ServicePointID" case altId = "ID" case name = "Name" case businessId = "BusinessID" } init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) // ServicePointID (from list/save endpoints) or ID (fallback) if let sid = try? container.decode(Int.self, forKey: .servicePointId) { id = String(sid) } else if let sid = try? container.decode(String.self, forKey: .servicePointId) { id = sid } else if let aid = try? container.decode(Int.self, forKey: .altId) { id = String(aid) } else if let aid = try? container.decode(String.self, forKey: .altId) { id = aid } else { id = "" } name = (try? container.decode(String.self, forKey: .name)) ?? "" if let bid = try? container.decode(Int.self, forKey: .businessId) { businessId = String(bid) } else { businessId = (try? container.decode(String.self, forKey: .businessId)) ?? "" } } func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .servicePointId) try container.encode(name, forKey: .name) try container.encode(businessId, forKey: .businessId) } }