// // Models.swift // tst // // Created by Vitaly Takmazov on 10.12.2019. // Copyright © 2019 com.juick. All rights reserved. // import Foundation typealias Model = Decodable & Identifiable typealias Root = Array struct Attachment: Decodable { var url: String } struct Entity: Decodable { var type: String var text: String var link: String? var start: Int? var end: Int? } struct User: Model { var id: Int var name: String var avatar: String? private enum CodingKeys : String, CodingKey { case id = "uid", name = "uname", avatar } } struct Message : Model { var id: Int var user: User var text : String? var attachment: Attachment? var entities: [Entity]? var tags: [String]? private enum CodingKeys : String, CodingKey { case id = "mid", user, text = "body", attachment, entities, tags } } struct Feed { var title: String var url: String var imageName: String }