// // KMAdvertisementModel.swift // KMAdvertisement // // Created by lizhe on 2022/11/30. // //参考链接 https://www.jianshu.com/p/a24cf8f37860 //func encode(of model: T) throws where T: Codable { // let encoder = JSONEncoder() // encoder.outputFormatting = .prettyPrinted // let encodedData = try encoder.encode(model) // print(String(data: encodedData, encoding: .utf8)!) //} //func decode(of jsonString: String, type: T.Type) throws -> T where T: Codable { // let data = jsonString.data(using: .utf8)! // let decoder = JSONDecoder() // let model = try! decoder.decode(T.self, from: data) // return model //} /** */ public struct KMAdvertisementModel: Codable { public let appName: KMAdvertisementAppNameType? //产品名 public let platform: KMAdvertisementPlatformType? //平台 public let showType: KMAdvertisementShowType? //显示类型 public let startTime: String? //开始时间 时间戳 public let endTime: String? //结束时间 时间戳 public let subscribeType: KMAdvertisementSubscribeType? //是否订阅 public let version: String? //小于等于此版本生效 let content:[Section] public struct Section: Codable { let sectionTitle: Text? let content: [Content] public struct Content: Codable { var index: Int? let title: Text? let imageURL: Image? let ipadImageURL: Image? let linkURL: Language? let tips: Language? let button: Text? let actionType: KMAdvertisementActionType? } } struct Text: Codable { let font: Font? let color: Color? let background: Background? let language: Language? } struct Font: Codable { let name: String? let size: Int? } struct Color: Codable { let height: ColorState? let normal: ColorState? struct ColorState: Codable { let dark: ColorInfo? let universal: ColorInfo? struct ColorInfo: Codable { var hex: String? var alpha: Float? } } } struct Background: Codable { let color: Color? let layer: Layer? struct Layer: Codable { let cornerRadius: CGFloat? let borderWidth: CGFloat? let borderColor: Color? } } struct Image: Codable { let height: Language? let normal: Language? let background: Background? } struct Language: Codable { let en: String? let zh_TW: String? let zh_CN: String? } }