-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathConnection+Storage.swift
56 lines (48 loc) · 1.67 KB
/
Connection+Storage.swift
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
//
// Connection+Storage.swift
// IFTTT SDK
//
// Copyright © 2020 IFTTT. All rights reserved.
//
import Foundation
extension Connection {
enum NativeServiceDescription: String, CaseIterable {
case location
}
struct ConnectionStorage: Hashable {
let id: String
var status: Status
let activeUserTriggers: Set<Trigger>
let allTriggers: Set<Trigger>
var enabledNativeServiceMap: [NativeServiceDescription: Bool]
init(id: String,
status: Status,
activeUserTriggers: Set<Trigger>,
allTriggers: Set<Trigger>,
enabledNativeServiceMap: [NativeServiceDescription: Bool]) {
self.id = id
self.status = status
self.activeUserTriggers = activeUserTriggers
self.allTriggers = allTriggers
self.enabledNativeServiceMap = enabledNativeServiceMap
}
init(id: String,
status: Status,
activeUserTriggers: Set<Trigger>,
allTriggers: Set<Trigger>) {
self.id = id
self.status = status
self.activeUserTriggers = activeUserTriggers
self.allTriggers = allTriggers
self.enabledNativeServiceMap = NativeServiceDescription.allCases.reduce(into: [:], { (dict, description) in
dict[description] = true
})
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
static func == (lhs: Connection.ConnectionStorage, rhs: Connection.ConnectionStorage) -> Bool {
return lhs.id == rhs.id
}
}
}