Tusker/Pachyderm/Sources/Pachyderm/Model/Mention.swift

34 lines
918 B
Swift
Raw Normal View History

2018-09-11 14:52:21 +00:00
//
// Mention.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
import WebURL
2018-09-11 14:52:21 +00:00
public struct Mention: Codable {
public let url: WebURL
2018-09-11 14:52:21 +00:00
public let username: String
public let acct: String
/// The instance-local ID of the user being mentioned.
2018-09-11 14:52:21 +00:00
public let id: String
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.username = try container.decode(String.self, forKey: .username)
self.acct = try container.decode(String.self, forKey: .acct)
self.id = try container.decode(String.self, forKey: .id)
self.url = try container.decode(WebURL.self, forKey: .url)
}
2018-09-11 14:52:21 +00:00
private enum CodingKeys: String, CodingKey {
case url
case username
case acct
case id
}
}