summaryrefslogtreecommitdiff
path: root/Hutch/Models/Meta.swift
blob: c0434bcc1e24ed7500eef905d480c9698878fc9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import Foundation

// MARK: - User Profile (full)

/// Extended user profile from meta.sr.ht with all fields from the `me` query.
struct UserProfile: Codable, Sendable {
    let username: String
    let canonicalName: String
    let email: String
    let url: String?
    let location: String?
    let bio: String?
    let avatar: String?
    let userType: String?
    let sshKeys: SSHKeyPage
    let pgpKeys: PGPKeyPage
    let paymentStatus: String?
    let subscription: Subscription?
}

// MARK: - SSH Key

struct SSHKey: Codable, Sendable, Identifiable {
    let id: Int
    let fingerprint: String
    let comment: String?
    let created: Date
    let lastUsed: Date?
}

struct SSHKeyPage: Codable, Sendable {
    let results: [SSHKey]
    let cursor: String?
}

// MARK: - PGP Key

struct PGPKey: Codable, Sendable, Identifiable {
    let id: Int
    let fingerprint: String
    let created: Date
}

struct PGPKeyPage: Codable, Sendable {
    let results: [PGPKey]
    let cursor: String?
}

// MARK: - Subscription

struct Subscription: Codable, Sendable {
    let status: String?
    let autorenew: Bool?
    let interval: String?
}

// MARK: - Personal Access Token

struct PersonalAccessToken: Codable, Sendable, Identifiable {
    let id: Int
    let issued: Date
    let expires: Date?
    let comment: String?
    let grants: String?
}