45 lines
897 B
Swift
Raw Normal View History

2020-04-16 18:00:27 -05:00
//
// TwitterUser.swift
// Account
//
// Created by Maurice Parker on 4/16/20.
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
//
import Foundation
struct TwitterUser: Codable {
let name: String?
2020-04-16 20:18:47 -05:00
let screenName: String?
2020-04-16 18:00:27 -05:00
let avatarURL: String?
enum CodingKeys: String, CodingKey {
case name = "name"
2020-04-16 20:18:47 -05:00
case screenName = "screen_name"
2020-04-16 18:00:27 -05:00
case avatarURL = "profile_image_url_https"
}
var url: String {
return "https://twitter.com/\(screenName ?? "")"
}
2020-04-18 13:46:28 -05:00
func renderAsHTML() -> String? {
2020-04-18 10:41:18 -05:00
var html = String()
html += "<div><a href=\"\(url)\">"
if let avatarURL = avatarURL {
html += "<img class=\"twitterAvatar\" src=\"\(avatarURL)\">"
}
html += "<span class=\"twitterUsername\">"
if let name = name {
html += " \(name)"
}
if let screenName = screenName {
html += " @\(screenName)"
}
html += "</span></a></div>"
return html
}
2020-04-16 18:00:27 -05:00
}