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 pathRemoteDomain.swift
More file actions
83 lines (75 loc) · 2.76 KB
/
Copy pathRemoteDomain.swift
File metadata and controls
83 lines (75 loc) · 2.76 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
76
77
78
79
80
81
82
83
import Foundation
@objc public enum DomainType: Int16 {
case registered
case mapped
case siteRedirect
case transfer
case wpCom
public var description: String {
switch self {
case .registered:
return NSLocalizedString("Registered Domain", comment: "Describes a domain that was registered with WordPress.com")
case .mapped:
return NSLocalizedString("Mapped Domain", comment: "Describes a domain that was mapped to WordPress.com, but registered elsewhere")
case .siteRedirect:
return NSLocalizedString("Site Redirect", comment: "Describes a site redirect domain")
case .wpCom:
return NSLocalizedString("Included with Site", comment: "Describes a standard *.wordpress.com site domain")
case .transfer:
return NSLocalizedString("Transferred Domain", comment: "Describes a domain that was transferred from elsewhere to wordpress.com")
}
}
init(domainJson: [String: Any]) {
self.init(
type: domainJson["domain"] as? String,
wpComDomain: domainJson["wpcom_domain"] as? Bool,
hasRegistration: domainJson["has_registration"] as? Bool
)
}
init(type: String?, wpComDomain: Bool?, hasRegistration: Bool?) {
if type == "redirect" {
self = .siteRedirect
} else if type == "transfer" {
self = .transfer
} else if wpComDomain == true {
self = .wpCom
} else if hasRegistration == true {
self = .registered
} else {
self = .mapped
}
}
}
public struct RemoteDomain {
public let domainName: String
public let isPrimaryDomain: Bool
public let domainType: DomainType
// Renewals / Expiry
public let autoRenewing: Bool
public let autoRenewalDate: String
public let expirySoon: Bool
public let expired: Bool
public let expiryDate: String
public init(domainName: String,
isPrimaryDomain: Bool,
domainType: DomainType,
autoRenewing: Bool? = nil,
autoRenewalDate: String? = nil,
expirySoon: Bool? = nil,
expired: Bool? = nil,
expiryDate: String? = nil) {
self.domainName = domainName
self.isPrimaryDomain = isPrimaryDomain
self.domainType = domainType
self.autoRenewing = autoRenewing ?? false
self.autoRenewalDate = autoRenewalDate ?? ""
self.expirySoon = expirySoon ?? false
self.expired = expired ?? false
self.expiryDate = expiryDate ?? ""
}
}
extension RemoteDomain: CustomStringConvertible {
public var description: String {
return "\(domainName) (\(domainType.description))"
}
}