2020-04-17 01:00:27 +02: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-17 03:18:47 +02:00
|
|
|
let screenName: String?
|
2020-04-17 01:00:27 +02:00
|
|
|
let avatarURL: String?
|
|
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case name = "name"
|
2020-04-17 03:18:47 +02:00
|
|
|
case screenName = "screen_name"
|
2020-04-17 01:00:27 +02:00
|
|
|
case avatarURL = "profile_image_url_https"
|
|
|
|
}
|
|
|
|
|
2020-04-17 22:31:13 +02:00
|
|
|
var url: String {
|
|
|
|
return "https://twitter.com/\(screenName ?? "")"
|
|
|
|
}
|
|
|
|
|
2020-04-18 20:46:28 +02:00
|
|
|
func renderAsHTML() -> String? {
|
2020-04-18 17:41:18 +02: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-17 01:00:27 +02:00
|
|
|
}
|