-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathDevice.swift
More file actions
76 lines (70 loc) · 2.53 KB
/
Copy pathDevice.swift
File metadata and controls
76 lines (70 loc) · 2.53 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
//
// Copyright © 2026 Stream.io Inc. All rights reserved.
//
import Foundation
public final class Device: Sendable, Codable, JSONEncodable {
/// Date/time of creation
public let createdAt: Date?
/// Whether device is disabled or not
public let disabled: Bool?
/// Reason explaining why device had been disabled
public let disabledReason: String?
/// Stable physical device identifier used to deduplicate pushes across push providers
public let hardwareId: String?
/// Device ID
public let id: String
/// Push provider
public let pushProvider: String
/// Push provider name
public let pushProviderName: String?
/// User ID
public let userId: String
/// When true the token is for Apple VoIP push notifications
public let voip: Bool?
init(createdAt: Date, disabled: Bool? = nil, disabledReason: String? = nil, hardwareId: String? = nil, id: String, pushProvider: String, pushProviderName: String? = nil, userId: String, voip: Bool? = nil) {
self.createdAt = createdAt
self.disabled = disabled
self.disabledReason = disabledReason
self.hardwareId = hardwareId
self.id = id
self.pushProvider = pushProvider
self.pushProviderName = pushProviderName
self.userId = userId
self.voip = voip
}
enum CodingKeys: String, CodingKey, CaseIterable {
case createdAt = "created_at"
case disabled
case disabledReason = "disabled_reason"
case hardwareId = "hardware_id"
case id
case pushProvider = "push_provider"
case pushProviderName = "push_provider_name"
case userId = "user_id"
case voip
}
}
extension Device: Hashable {
public static func == (lhs: Device, rhs: Device) -> Bool {
lhs.createdAt == rhs.createdAt &&
lhs.disabled == rhs.disabled &&
lhs.disabledReason == rhs.disabledReason &&
lhs.hardwareId == rhs.hardwareId &&
lhs.id == rhs.id &&
lhs.pushProvider == rhs.pushProvider &&
lhs.pushProviderName == rhs.pushProviderName &&
lhs.userId == rhs.userId &&
lhs.voip == rhs.voip
}
public func hash(into hasher: inout Hasher) {
hasher.combine(createdAt)
hasher.combine(disabled)
hasher.combine(disabledReason)
hasher.combine(hardwareId)
hasher.combine(id)
hasher.combine(pushProvider)
hasher.combine(pushProviderName)
hasher.combine(userId)
hasher.combine(voip)
}
}