import Foundation public struct InboxAction: Codable, Sendable { public let id: String; public let label: String; public let url: String? } public struct InboxMessage: Codable, Identifiable, Sendable { public let id: String; public let recipientId: String; public let title: String; public let body: String public let purpose: String; public let category: String; public let url: String?; public let actions: [InboxAction]? public let createdAt: String; public let readAt: String?; public let archivedAt: String? } public struct InboxSnapshot: Codable, Sendable { public let messages: [InboxMessage]; public let unreadCount: Int } public struct InboxBranding: Codable, Sendable { public let displayName: String?; public let brandColor: String?; public let brandTextColor: String?; public let logoUrl: String? } public struct QuietHours: Codable, Sendable { public let start: String; public let end: String; public let days: [Int] public init(start: String, end: String, days: [Int]) { self.start=start; self.end=end; self.days=days } } public struct DeliveryRules: Codable, Sendable { public let timezone: String; public let quietHours: QuietHours?; public let marketingDailyLimit: Int? public init(timezone: String, quietHours: QuietHours? = nil, marketingDailyLimit: Int? = nil) { self.timezone=timezone; self.quietHours=quietHours; self.marketingDailyLimit=marketingDailyLimit } // Null explicitly clears a saved rule; omission would preserve it. public func encode(to encoder: Encoder) throws { var c=encoder.container(keyedBy: CodingKeys.self); try c.encode(timezone, forKey:.timezone) try c.encode(quietHours, forKey:.quietHours); try c.encode(marketingDailyLimit, forKey:.marketingDailyLimit) } } public struct CategoryPreference: Codable, Sendable { public let category: String; public let inAppEnabled: Int; public let marketingEnabled: Int } public struct ChannelPreference: Codable, Sendable { public let channel: String; public let category: String; public let enabled: Int } public struct InboxPreferences: Codable, Sendable { public let branding: InboxBranding?; public let deliveryRules: DeliveryRules; public let preferences: [CategoryPreference]; public let channelPreferences: [ChannelPreference] } public struct PreferenceInput: Encodable, Sendable { public let category: String; public let inAppEnabled: Bool; public let marketingEnabled: Bool; public let externalChannels: [String:Bool]?; public let deliveryRules: DeliveryRules? public init(category: String, inAppEnabled: Bool, marketingEnabled: Bool, externalChannels: [String:Bool]? = nil, deliveryRules: DeliveryRules? = nil) { self.category=category; self.inAppEnabled=inAppEnabled; self.marketingEnabled=marketingEnabled; self.externalChannels=externalChannels; self.deliveryRules=deliveryRules } } public enum MobilePlatform: String, Codable, Sendable { case android, ios } public struct MobileRegistration: Encodable, Sendable { public let connectionId: String; public let installationId: String; public let name: String; public let platform: MobilePlatform; public let token: String; public let marketingConsent: Bool; public let consentEvidence: String public init(connectionId: String, installationId: String, name: String, platform: MobilePlatform = .ios, token: String, marketingConsent: Bool = false, consentEvidence: String = "") { self.connectionId=connectionId; self.installationId=installationId; self.name=name; self.platform=platform; self.token=token; self.marketingConsent=marketingConsent; self.consentEvidence=consentEvidence } } public struct MobileDevice: Decodable, Sendable { public let id: String; public let connectionId: String; public let installationId: String; public let name: String; public let platform: String; public let active: Int; public let revision: Int; public let createdAt: String; public let updatedAt: String } public struct WebDevice: Decodable, Sendable { public let id: String; public let connectionId: String; public let name: String; public let active: Int; public let createdAt: String; public let updatedAt: String } public struct MobileConnection: Decodable, Sendable { public let id: String; public let provider: String; public let applicationId: String; public let isDefault: Bool } public struct WebConnection: Decodable, Sendable { public let id: String; public let publicKey: String; public let isDefault: Bool } public struct InboxDevices: Decodable, Sendable { public let devices: [WebDevice]; public let mobileDevices: [MobileDevice]; public let connections: [WebConnection]; public let mobileConnections: [MobileConnection] } public struct DeviceResult: Decodable, Sendable { public let id: String; public let revision: Int?; public let replayed: Bool } public struct MessageResult: Decodable, Sendable { public let id: String } struct EmptyResult: Decodable { } public struct InboxError: Error, LocalizedError, Sendable { public let code: String; public let status: Int; public let message: String public var errorDescription: String? { message } public init(code: String, status: Int = 0, message: String) { self.code=code; self.status=status; self.message=message } }