summaryrefslogtreecommitdiff
path: root/Hutch/Networking/SRHTService.swift
blob: 3aa805fd3667c1029e3a617d87243aa308b069d8 (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
import Foundation

/// Each SourceHut service exposes its own GraphQL endpoint.
enum SRHTService: String, Codable, Sendable, CaseIterable {
    case meta
    case hub
    case git
    case hg
    case builds
    case lists
    case todo
    case paste
    case pages
    case man

    /// The GraphQL endpoint URL for this service.
    var url: URL {
        switch self {
        case .hub:
            URL(string: "https://sr.ht/query")!
        default:
            // Force-unwrap is safe here — these are compile-time constant strings.
            URL(string: "https://\(rawValue).sr.ht/query")!
        }
    }

    var displayName: String {
        switch self {
        case .meta:   "Meta"
        case .hub:    "Hub"
        case .git:    "Git"
        case .hg:     "Mercurial"
        case .builds: "Builds"
        case .lists:  "Lists"
        case .todo:   "Todo"
        case .paste:  "Paste"
        case .pages:  "Pages"
        case .man:    "Man"
        }
    }
}