This repository was archived by the owner on Sep 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathJetpackScan.swift
More file actions
75 lines (56 loc) · 2.27 KB
/
Copy pathJetpackScan.swift
File metadata and controls
75 lines (56 loc) · 2.27 KB
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
66
67
68
69
70
71
72
73
74
75
import Foundation
public struct JetpackScan: Decodable {
public enum JetpackScanState: String, Decodable, UnknownCaseRepresentable {
case idle
case scanning
case unavailable
case provisioning
// Internal states that don't come from the server
// The scan will be in this state when its in the process of fixing any fixable threats
case fixingThreats
case unknown
static let unknownCase: Self = .unknown
}
/// Whether the scan feature is available or not
public var isEnabled: Bool {
return (state != .unavailable) && (state != .unknown)
}
/// The state of the current scan
public var state: JetpackScanState
/// If a scan is in an unavailable state, this will return the reason
public var reason: String?
/// If there is a scan in progress, this will return its status
public var current: JetpackScanStatus?
/// Scan Status for the most recent scan
/// This will be nil if there is currently a scan taking place
public var mostRecent: JetpackScanStatus?
/// An array of the current threats
/// During a scan this will return the previous scans threats
public var threats: [JetpackScanThreat]?
/// A limited representation of the users credientals for each role
public var credentials: [JetpackScanCredentials]?
/// Internal var that doesn't come from the server
/// An array of the threats being fixed current
public var threatFixStatus: [JetpackThreatFixStatus]?
// MARK: - Private: Decodable
private enum CodingKeys: String, CodingKey {
case mostRecent, state, reason, current, threats, credentials
}
}
// MARK: - JetpackScanStatus
public struct JetpackScanStatus: Decodable {
public var isInitial: Bool
/// The date the scan started
public var startDate: Date?
/// The progress of the scan from 0 - 100
public var progress: Int
/// How long the scan took / is taking
public var duration: TimeInterval?
/// If there was an error finishing the scan
/// This will only be available for past scans
public var didFail: Bool?
private enum CodingKeys: String, CodingKey {
case startDate = "timestamp", didFail = "error"
case duration, progress, isInitial
}
}