61 lines
1.4 KiB
Swift
61 lines
1.4 KiB
Swift
|
//
|
||
|
// Instance.swift
|
||
|
// Pachyderm
|
||
|
//
|
||
|
// Created by Shadowfacts on 9/9/18.
|
||
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
public class Instance: Decodable, ClientModel {
|
||
|
var client: Client! {
|
||
|
didSet {
|
||
|
contactAccount.client = client
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public let uri: String
|
||
|
public let title: String
|
||
|
public let description: String
|
||
|
public let email: String
|
||
|
public let version: String
|
||
|
public let urls: [String: URL]
|
||
|
public let languages: [String]
|
||
|
public let contactAccount: Account
|
||
|
|
||
|
// MARK: Unofficial additions to the Mastodon API.
|
||
|
public let stats: Stats?
|
||
|
public let thumbnail: URL?
|
||
|
public let maxStatusCharacters: Int?
|
||
|
|
||
|
private enum CodingKeys: String, CodingKey {
|
||
|
case uri
|
||
|
case title
|
||
|
case description
|
||
|
case email
|
||
|
case version
|
||
|
case urls
|
||
|
case languages
|
||
|
case contactAccount = "contact_account"
|
||
|
|
||
|
case stats
|
||
|
case thumbnail
|
||
|
case maxStatusCharacters = "max_toot_chars"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension Instance {
|
||
|
public class Stats: Decodable {
|
||
|
public let domainCount: Int?
|
||
|
public let statusCount: Int?
|
||
|
public let userCount: Int?
|
||
|
|
||
|
private enum CodingKeys: String, CodingKey {
|
||
|
case domainCount = "domain_count"
|
||
|
case statusCount = "status_count"
|
||
|
case userCount = "user_count"
|
||
|
}
|
||
|
}
|
||
|
}
|